Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Multiple Actions for a Rollover

    Hello:

    I am a newbie to learning Javascript. I have some problems with a file.

    The goal of the file is that when it loads in a browser, the 1st image is displayed in the top left (image 7441805.gif), along with the following three titles to the right of the image, as listed below:

    Java Demystified
    OOP Demystified
    Data Structures Demystified

    When you place the mouse over "Java Demystified," the 7441805.gif image should still appear (which it does)), and a new window
    should pop-up and stay on the screen displaying "10% Discount for Java Demystified" until the user decides to do away with
    the new window by clicking on the "X". The new window does appear for about less than a second , and then goes away
    (actually it continuously flashes on and off very quickly), which is not what I want.


    When you place the mouse over "OOP Demystified," the 0072253630.jpg image should appear (which it does), and a new window
    should pop-up and stay on the screen displaying "20% Discount for OOP Demystified" until the user decides to do away with the new
    window by clicking on the "X". The new window does appear for about less than a second , and then goes away
    (actually it continuously flashes on and off very quickly), which is not what I want.

    When you place the mouse over "Data Structures Demystified," the 7417436.gif image should appear (which it does), and a new window
    should pop-up and stay on the screen displaying "15% Discount for Data Structures Demystified" until the user decides to do away with the new
    window by clicking on the "X". The new window does appear for about less than a second , and then goes away
    (actually it continuously flashes on and off very quickly), which is not what I want.

    All of the files are loaded on my laptop, which is using Vista, is 32bit, has the IE9 browser installed, and pop-ups are disabled.
    When I try to use Mozilla (version 6.0), I am unable to disable the pop-ups, and therefore can not even get any new windows to open.

    I would appreciate your help.

    The html file is below:

    [CODE]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">


    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">


    <head>

    <title>Open Window</title>


    <meta http-equiv="Content-type" content="text/html; charset=iso-8859-1" />


    <meta http-equiv="Content-Language" content="en-us" />

    <meta name="description" content="XYZ" />
    <meta name="keywords" content="XYZ" />



    <!-- the absolute pathname of this file is: -->

    <!-- C:\MISCSUP2_10_17_8\MISCSUP2\Javascript_Demystified_Download_Working\ -->
    <!-- Ch_12_Page241.html -->


    <!-- this file was created on Wednesday, 8/24/11: -->
    <!-- this file was updated on Wednesday, 8/24/11: -->

    <script language="Javascript" type="text/javascript">
    <!--
    function OpenNewWindow(book) {
    if (book== 1)
    {
    document.cover.src='7441805.gif'
    MyWindow = window.open('', 'myAdWin', 'titlebar="0" status="0", toolbar="0", location="0", menubar="0", directories="0", resizable="0", height="50", width="150",left="500",top="400"')
    MyWindow.document.write('10% Discount for Java Demystified!')
    }
    if (book== 2)
    {
    document.cover.src='0072253630.jpg'
    MyWindow = window.open('', 'myAdWin', 'titlebar="0" status="0", toolbar="0", location="0", menubar="0", directories="0", resizable="0", height="50", width="150",left="500",top="500"')
    MyWindow.document.write('20% Discount for OOP Demystified!')
    }
    if (book== 3)
    {
    document.cover.src='7417436.gif'
    MyWindow = window.open('', 'myAdWin', 'titlebar="0" status="0", toolbar="0", location="0", menubar="0", directories="0", resizable="0", height="50", width="150",left="500",top="600"')
    MyWindow.document.write("15% Discount for Data Structures Demystified!")
    }
    }
    -->
    </script>


    </head>

    <body>

    <table width="100%" border="0">

    <tbody>

    <tr valign="top">

    <td width="50">
    <a>
    <img height="92" src="7441805.gif" width="70" border="0" name="cover">
    </a>
    </td>


    <td>
    <img height="1" src="" width="10">
    </td>


    <td>
    <a onmouseover="OpenNewWindow(1)" onmouseout="MyWindow.close()">
    <b><u>Java Demystified </u></b>
    </a>

    <br>

    <a onmouseover="OpenNewWindow(2)" onmouseout="MyWindow.close()">
    <b><u>OOP Demystified</u></b>
    </a>

    <br>

    <a onmouseover="OpenNewWindow(3)" onmouseout="MyWindow.close()">
    <b><u>Data Structures Demystified</u></b>
    </a>

    </td>

    </tr>


    </tbody>


    </table>


    </body>


    </html>[ICODE]
    Attached Images Attached Images    

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,174
    Thanks
    75
    Thanked 4,339 Times in 4,305 Posts
    You are (incorrectly) calling to close the window when the mouse moves OUT of each of those rollovers.

    If the window is supposed to stay there for 10 seconds, you do *NOT* want the onmouseout handlers, at all.

    No place in there do you have any timeout code for the 10 seconds until close that you say is required.

    I'm assuming this is homework, so I won't say more than that for now.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you for your response!!!

    This is not homework from a College, etc.. I am trying to learn this material on my own. The book that I am using has too many errors and is too old. The book is "Javascript Demystified A SELF-TEACHING GUIDE" by Jim Keogh, copyright 2005. The coding is from pages 241 and 242. If you know of any good Javascript books for beginners (preferably in color) I would appreciate it.

    I did remove the onmouseout handlers and it worked properly.

    I did learn a bit more about temporarily disabling the pop-up blockers for Mozilla and Opera, which involves slightly different techniques. The info. that I learned is as follows:

    For Firefox, go to Tools, Options, click on the content section, and then uncheck the "Block popup windows".

    For Opera, you need to do 4 sets of things:

    1) Click the Alt key, Tools, Advanced, Blocked Content

    2) Click the Alt key, Quick Preferences, Open All Pop-Ups

    3) Click the Alt key, Tools, Quick Preferences, Edit Site Preferences, Content, and uncheck enable content blocking.

    4) Click the Alt key, Tools, Preferences, General, and made sure that Open all pop-ups are selected.

    Then my file worked, but I noticed that the new pop-up window gets placed behind the the existing window (when the mouse is placed over a title) along with its associated tab.

    Again, thank you.

  • #4
    New to the CF scene
    Join Date
    Aug 2011
    Location
    India
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am a newbie to learning Javascript. I have some problems with a file that was copied from the book
    "JavaScript Demystified A SELF-TEACHING GUIDE" by Jim Keogh, copyright 2005, page 240 (figure 12-4).


    The goal of the file is that when it loads in a browser, the 1st image is displayed in the top left (image 7441805.gif),

    along with the following three titles to the right of the image, as listed below:

    Java Demystified
    OOP Demystified
    Data Structures Demystified

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,174
    Thanks
    75
    Thanked 4,339 Times in 4,305 Posts
    You can force the popup to the front by using
    Code:
    var w = window.open(....);
    w.focus();
    The language="javascript" is obsolescent and unneeded. And the need to use <!-- to hide JS from old browsers disappeared when MSIE 4 took over from MSIE 3. In 1998. (And, besides, your page is worthless if JS doesn't work!)

    Code:
    <html>
    <head>
    <script type="text/javascript">
    // create arrays with unused element zero, since your books are numbered 1,2,3
    var images = [ null, "7441805.gif", "0072253630.jpg", "7417436.gif" ];
    var captions = [
            null,
            "10% Discount for Java Demystified",
            "20% Discount for OOP Demystified!",
            "15% Discount for Data Structures Demystified!" ];
    
    var MyWindow = null;
    
    function closeMyWindow( )
    {
        if ( MyWindow != null )
        {
            MyWindow.close();
            MyWindow = null;
        }
    }
    
    function OpenNewWindow(book) 
    {
        closeMyWindow(); // in case it was open still    
    
        document.getElementById("cover").src = images[book];
        document.getElementById("cover").style.visibility = "visible";
        MyWindow = window.open("", "myAdWin",
             "titlebar=0,status=0,toolbar=0,location=0,menubar=0,directories=0,
              resizable=0,height=50,width=150,left=500,top=400");
        MyWindow.document.write( captions[book] );
        MyWindow.focus( );
        setTimeout( closeMyWindow, 10000 );
    }
    </script>
    </head>
    <body>
    <img height="92" width="70" border="0" id="cover" style="visibility: hidden;">
    <br/>
    <a onmouseover="OpenNewWindow(1)">Java Demystified</a>
    <br/>
    <a onmouseover="OpenNewWindow(2)">OOP Demystified</a>
    <br/>
    <a onmouseover="OpenNewWindow(3)">Data Structures Demystified</a>
    </body>
    </html>
    Totally untested code, off the top of my head.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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