SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 40 of 40
  1. #26
    SitePoint Zealot
    Join Date
    Feb 2011
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks but why the need for this script in the body?

    Code:
    <script type="text/javascript">
    
            window.onload = function() {
    
                openindex();
    
            };
    
        </script>
    What I am seeing online does not have a script tag in the body, only the

    onLoad="openindex()"

    so what doesn't that work please?

  2. #27
    SitePoint Addict
    Join Date
    Dec 2005
    Posts
    336
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I am pretty sure you mean it to read as:
    PHP Code:
    <body onload="openindex();"></body
    The way I presented allowed the Javascript to be trigged after the rest of the HTML was already loaded, hence "onload"

  3. #28
    SitePoint Zealot
    Join Date
    Feb 2011
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think I was missing a key issue, when I was told to place the function "between the Body tags" , I was thinking like this:

    Code:
    <body>
    
    function goes here
    
    </body>
    but what I am seeing now is the code needs to go inside the <body> tag like this:

    Code:
    <body ..function goes here>
    
    </body>
    Is that correct?

  4. #29
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by mikehende View Post
    This is an entire script, can anyone tell me exactly why it is not opening the new window please?
    The parenthesis must not be separated from the function name. Not even by a space.

    Code javascript:
    // good
    function openWindow() {
     
    }
    openWindow();
     
    // bad
    function openWindow () {
     
    }
    openWindow ();
     
    // ugly
    function openWindow () {
     
    }
    openWindow();


    When there is no function name, the word "function" and the parenthesis should be separated by a space, to help prevent confusion. The name of the function though must still have no separation from the invoking parenthesis.

    Code javascript:
    var openWindow;
     
    // good
    openWindow = function () {
     
    };
    openWindow();
     
    // bad
    openWindow = function () {
     
    };
    openWindow ();
     
    // ugly
    openWindow = function() {
     
    };
    openWindow();
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #30
    SitePoint Zealot
    Join Date
    Feb 2011
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To further break down this script, I don't see the need for these?

    Code:
    w.write("<HTML>")
    w.write("<TITLE>")
    I erased them from my script and in the html page everything works fine without them?

    Also regarding this:

    Code:
    OpenWindow.document.write("<font size=+4>New Window</font><P>");
    What is the <P> for?

  6. #31
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by mikehende View Post
    Also regarding this:

    Code:
    OpenWindow.document.write("<font size=+4>New Window</font><P>");
    What is the <P> for?
    Hssss - evil fontses!

    I suspect that the <P> is the author's well-intentioned but badly maligned attempt to add some vertical spacing inbetween.

    Typically today a class name might be applied, so that such presentational things may be controlled from there.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  7. #32
    SitePoint Zealot
    Join Date
    Feb 2011
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, thanks, please disregard the first part of my question, I had overlooked that this script included an HTML doc.

  8. #33
    SitePoint Zealot
    Join Date
    Feb 2011
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Studying this section now:

    JavaScript Primers #15

    This script is working on that page for "Assignment 15":

    Code:
    <html>
        <head>
        </head>
        <body bgcolor="white">
        <center>
        <h1>Andree Growney</h1>
    	<p>
        <a href="" onMouseOver="document.pic1.src='bubble2.gif' "
            onMouseOut="document.pic1.src='bubble1.gif'">
        <img src="bubble1.gif" border=0 name="pic1"></a></p>
        </body>
        </html>
    but I am not seeing the image on my html page? I have placed both images and the html page named test.html on my C drive into a folder named "Test", help?

  9. #34
    SitePoint Zealot
    Join Date
    Feb 2011
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is my entire html page:
    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>
    <meta http-equiv="Content-type" content="text/html; charset=ISO-8859-1" />
    <title>FunKaDeLic</title>
    <link type="text/css" rel="stylesheet" href="funkadelic.css" />
    
    <script type="text/javascript" >
     
     </script>
    
    </head>
    
     <body bgcolor="white">
        <center>
        <h1>Andree Growney</h1>
    	<p>
        <a href="" onMouseOver="document.pic1.src='bubble2.gif' "
            onMouseOut="document.pic1.src='bubble1.gif'">
        <img src="bubble1.gif" border=0 name="pic1"></a></p>
    
    </body>
    
    </html>

    Please see attached pic of the Test folder
    Attached Images Attached Images

  10. #35
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    If you're testing this in Internet Explorer, have you allowed local scripting?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  11. #36
    SitePoint Zealot
    Join Date
    Feb 2011
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was testing in FF Beta 4.0, I just checked with IE, it works, thanks, will look for the setting in FF to allow scripting, the menu is totally different,

  12. #37
    SitePoint Zealot
    Join Date
    Feb 2011
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Far as I am seeing here Javascript is enabled, see attachment, any idea why I am having this problem please?
    Attached Images Attached Images

  13. #38
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    You're using Firefox, right.

    Does the error console give you any info?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  14. #39
    SitePoint Zealot
    Join Date
    Feb 2011
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry Paul, never heard of the "error console" before? Have to sign off now, been a very long day dealing with viruses from 2 pc's here and trying to study JS at the same time, will check back in the morning, thanks..

  15. #40
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by mikehende View Post
    Sorry Paul, never heard of the "error console" before? Have to sign off now, been a very long day dealing with viruses from 2 pc's here and trying to study JS at the same time, will check back in the morning, thanks..
    Here the menu reference for Firefox 4 so that you can get more info on it.
    Menu Reference | How to | Firefox Help
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


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
  •