Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
javascript: onload resize popup

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Client-side
View previous topic :: View next topic  
Author Message
keye



Joined: 24 Nov 2003
Posts: 2465
Location: Paris - France

PostPosted: 07.09.2007 15:03    Post subject: javascript: onload resize popup Add user to your forum ignore list Reply with quote

bok svima!
mozete li mi , molim vas reci, kako napraviti resize nekog popup-a u duzinu, ovisno o sadrzaju?
sadrzaj je dinamican znaci ne znam koliko je popup visok, znam samo sirinu, no ove scriptove sto sam dosad vidjela tretiraju width ali height mi se slozi kako mu se hoce: kao da postoji neki default height (iako ga nigdje nemam).

postoji li mogucnost regulacije visine tog popupa? ako je sadrzaj dug scroll nije problem no kad imam deset linija sadrzaja ostane mi praznog okolo. no nikad ne znam koliki mi je sadrzaj.

unaprijed puno hvala


ps. naravno ideja nije moja nego od obozavanog klijenta Smile

_________________
Google is a blind person
Back to top
View user's profile Send private message Visit poster's website
fun.ky



Joined: 05 Jan 2006
Posts: 365
Location: Mostar

PostPosted: 09.09.2007 06:29    Post subject: Add user to your forum ignore list Reply with quote

Poz, sljedeci kod postavi u neki.js file koji ces ucitavati na stranici gdje se nalaze linkovi za popup.

Code:
window.onload = attachEvents;


function attachEvents()
{
   var popupList = getElementsByClassName("popUp");
   for(var i = 0; i < popupList.length; i++)
   {
      if(popupList[i].href != "undefined")
      {
         popupList[i].onclick = doIt;
      }
         
   }
}

function doIt()
{
   var popup = makePopup(this.href, 640, 480, 'resize');
   popup.onload = function()
   {
      getHeight(popup);
   }
   return popup.closed;
}

function getElementsByClassName (className) {
  var all = document.all ? document.all :
    document.getElementsByTagName('*');
  var elements = new Array();
  for (var e = 0; e < all.length; e++)
  {
    if (all[e].className == className)
      elements[elements.length] = all[e];
  }
  return elements;
}

function makePopup(url, width, height, overflow)
{
   var win = window.open(url, '',
   'width=' + width + ',height=' + height
   + ',scrollbars=' + (/^(scroll|both)$/.test(overflow) ?
   'yes' : 'no')
   + ',resizable=' + (/^(resize|both)$/.test(overflow) ?
   'yes' : 'no')
   + ',status=yes,toolbar=no,menubar=no,location=no'
   );
   return win;
}

function getHeight(popup)
{
   var y;
   var test1 = popup.document.body.scrollHeight;
   var test2 = popup.document.body.offsetHeight
   
   if (test1 > test2) // all but Explorer Mac
   {
      y = popup.document.body.scrollHeight;
   }
   else // Explorer Mac;
       //would also work in Explorer 6 Strict, Mozilla and Safari
   {
      y = popup.document.body.offsetHeight;
   }   
   setHeight(y, popup);
}

function setHeight(y, popup)
{
   y += 20;
   if (popup.self.innerHeight) // all except Explorer
   {
      popup.self.innerHeight = y;
   }
   else if (popup.document.documentElement && popup.document.documentElement.clientHeight)
      // Explorer 6 Strict Mode
   {
      popup.document.documentElement.clientHeight = y;
   }
   else if (popup.document.body) // other Explorers
   {
      popup.document.body.clientHeight = y;
   }
}


Predpostavio sam da koristiš anchor elemenat (ako nisi trebat ce malo ispraviti kod)

uglavnom da bi ti ovo funkcionisalo trebas uraditi sljedeca 2 koraka:
1 - (već sam rekao al evo ponoov) - Sav JS code kopirati u neki js file koji ce biti uključen u stranicu gdje su linkovi prema popup -ima

2. Staviti class-u popUp na link koji zelis da se otvara u popup-u

sto bi izgledalo ovako na kraju ovako
Code:
<a href="Folder/NekiLink.html" class="popUp">Click</a>


nadam se da ce pomoci.

Poz

_________________
There is no style definition for good music!
Back to top
View user's profile Send private message Visit poster's website Twitter profile
keye



Joined: 24 Nov 2003
Posts: 2465
Location: Paris - France

PostPosted: 10.09.2007 19:25    Post subject: Add user to your forum ignore list Reply with quote

iskreno hvala, probam ovih dana pa javim Very Happy

_________________
Google is a blind person
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Client-side All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group