SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jun 2004
    Location
    d
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Pop up window doesn't work

    Hi all,

    I want to use the following code on my web page but, it doesn't work they way I want it to.

    Firts, I want the pop up window to close after a certain amount of time but, instead of the pop up closing, it closes the previous page (the main page).

    Second, I want to add a close button to the pop up window but, it appears on the main page also.

    What could I be doing wrong?? I tried many times, switched the lines around but it wouldn't work. Any help will be appreciated

    THANK YOU!!!!

    <HEAD>

    <SCRIPT LANGUAGE="JavaScript">


    <!-- Begin


    function CaricaFoto(img){
    foto1= new Image();
    foto1.src=(img);
    Controlla(img);

    }
    function Controlla(img){
    if((foto1.width!=0)&&(foto1.height!=0)){
    viewFoto(img);
    }
    else{

    funzione="Controlla('"+img+"')";
    intervallo=setTimeout(funzione,20);
    }
    }
    function viewFoto(img){
    largh=foto1.width+20;
    altez=foto1.height+20;
    stringa="width="+largh+",height="+altez;
    finestra=window.open(img,"",stringa);

    }


    function openWin( windowURL, windowName, windowFeatures ) {
    return window.open( windowURL, windowName, windowFeatures ) ;
    }

    // End -->


    </script>
    </head>



    <body onLoad="setTimeout(window.close, 5000)">

    <form><input TYPE="button" VALUE="Close Window" onClick="window.close()">&nbsp;&nbsp;&nbsp;</form>

    <A HREF="javascript:CaricaFoto('51.jpg')">
    <IMG SRC="51a.jpg">


    <a href="javascript:void()" onMouseOver="JavaScript: newWindow = openWin('51.jpg'); newWindow.focus()"" onClick=";return

    false">mouse here to see large image</a>



    </body>

  2. #2
    SitePoint Member QMaze's Avatar
    Join Date
    Jun 2004
    Location
    Planet Earth
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you explain your code a little better...

    Where is all this code? On the main page? More info.


  3. #3
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First, a little clarification: The pseudo-URL (which this forum's software insists on misdisplaying as java_script_) only belongs as part of an href value, not as values for event handlers like onclick. What the pseudo-URL does is allow a link to access the JavaScript interpreter as if it were a standard target URL, like "http://www.whatever.com/".

    The easiest way to get your commands to apply to the window you have opened is to assign the window to a variable as in:
    var winOne=window.open("URL_of_page","window_name","window_options");

    Then any changes can be applied to the window through the variable as in:
    winOne.location.href="http://www.whatnot.com/"
    or
    winOne.close();


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
  •