Results 1 to 9 of 9

Thread: Please Help To Modify Script.

  1. #1
    Join Date
    Jan 2006
    Posts
    234
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Question Please Help To Modify Script.

    Hi Everybody.

    Someone please tell me what to change or add to this script below to close the image popup if clicked somewhere in the page.
    Here the script:
    Code:
    var win=null;
    function NewWindow(mypage,myname,w,h,scroll,pos){
    if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
    if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
    else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
    settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
    win=window.open(mypage,myname,settings);}
    And here the link that opens the image popup:
    Code:
    <p><a href="Images/PopUps/nang_paya.html" onclick="NewWindow(this.href,'popup','275','400','no','center');return false" onfocus="this.blur()"><img src="Images/Phra Nang Phaya (1.8).jpg" alt="Nang Paya" width="100" height="149" border="0" /></a></p>
    I did this before but can't remember how I did it.

    Thanks in advance.
    Cheng

  2. #2
    Join Date
    Nov 2006
    Location
    IA
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I do not recognize the script. Sorry!

  3. #3
    Join Date
    Nov 2006
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Code:
    var win=null;
    function NewWindow(mypage,myname,w,h,scroll,pos){
    if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
    if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
    else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
    settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
    win=window.open(mypage,myname,settings);
    onClick="javascript:window.close();">}
    The bold is what i added. I am pretty sure that is how you can acomplish this.
    Last edited by GhettoT; 12-04-2006 at 10:32 PM.

  4. #4
    Join Date
    Jan 2006
    Posts
    234
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    Hi GhettoT.

    Thanks but that's not the right code.
    With this code the popup wont open at all.
    I remember that it was something similar like this:
    Code:
    <script type="text/javascript">
    if (self.opener)
    window.onblur=function(){self.close();}
    </script>
    With this script here the popup closes like I want to but there is no content inside the window, but it schould be similar to this:
    Code:
    var win=null;
    function NewWindow(mypage,myname,w,h,scroll,pos){
    if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
    if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
    else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
    settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,re sizable=no';
    win=window.open('',myname,settings);
    win.document.write('<body style="margin:0;padding:0;" onblur="self.close()"><img src="'+mypage+'">');
    win.document.close();
    }
    Thanks again.
    Cheng

  5. #5
    Join Date
    Nov 2006
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    OK, this is a long shot and i think will probably not work...(i'm optimistic though) try this:
    Code:
    <a onClick="javascript:window.close();">
    var win=null;
    function NewWindow(mypage,myname,w,h,scroll,pos){
    if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
    if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
    else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
    settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
    win=window.open(mypage,myname,settings);
    }</a>
    I think that would make the whole window a hyperlink to onClick="javascript:window.close();" so it would close... Maybe not though!

    Sorry i'm still learning...

    -GT

  6. #6
    Join Date
    Jan 2006
    Posts
    234
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    Hi GhettoT.

    No that's not it.
    See ths script here is working but only to open an image if I specify an url there is no content inside the popup.
    Code:
    var win=null;
    function NewWindow(mypage,myname,w,h,scroll,pos){
    if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
    if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
    else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
    settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,re sizable=no';
    win=window.open('',myname,settings);
    win.document.write('<body style="margin:0;padding:0;" onblur="self.close()"><img src="'+mypage+'">');
    win.document.close();
    }
    Cheng

  7. #7
    Join Date
    Nov 2006
    Location
    IA
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow oh is this the pop-it menu

    If so maybe I can help

    Put the url on a seperate link as that of the image

  8. #8
    Join Date
    Jan 2006
    Posts
    234
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    Hi Masterskinnie.

    Thanks for your reply.
    I'm not sure if I understand you correctly but if you mean to use a text link instaed of the image as a link to the URL that is not working.
    If you meant something else than that please let me know and explain it a little better so I can try it out.

    Thanks again.
    Cheng

  9. #9
    Join Date
    Nov 2006
    Location
    IA
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post

    I mean if you are using the pop-it menu at the url http://www.dynamicdrive.com/dynamicindex1/popit.htm
    then you should have what looks like this

    Code:
    linkset[0]='<a href="http://www.west-bend.k12.ia.us">Home</a>'
    
    linkset[1]='<a href="http://www.west-bend.k12.ia.us/wbmnew/announcements/dailyannouncements.htm">HS Announcements</a>'
    linkset[1]+='<a href="http://www.west-bend.k12.ia.us/wbmnew/msannouncements/msba.htm">MS Announcements</a>'
    linkset[1]+='<a href="http://www.west-bend.k12.ia.us/wbmnew/announcements/Decembermenu.html">December Lunch Menu</a>'
    What you should do in this case is to do this:

    Code:
    linkset[?your number here?]='<a href="?url here?"><img src="your image name here"></a>'
    linkset[?same number?]+='<a href="?same url?>"text here"</a>'
    Both the image and the regular link will go to the same page and both are on there though they are both considered separate links by the script

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •