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 12 of 12
  1. #1
    New Coder
    Join Date
    Jul 2002
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    OnClick Doesn't Work In Internet Explorer 6

    The following javascript only works in Netscape. It doesn't work in Internet Explorer 6, it keeps giving me errors. Is there anything i can do that would fix the javascript and make in compatible with all netscape and internet explorer browsers?

    <HTML>
    <HEAD>
    <TITLE>Untitled</TITLE>

    <SCRIPT LANGUAGE=JavaScript>
    <!--
    timer=""
    whereto=new Array()
    whereto[whereto.length]="http://www.yahoo.com"
    whereto[whereto.length]="http://www.google.com"
    whereto[whereto.length]="http://www.huntingground.net"
    whereto[whereto.length]="http://www.microsoft.com"
    whereto[whereto.length]="http://www.freeserve.co.uk"
    whereto[whereto.length]="http://www.yahoo.com"

    function playSound(name,where){
    clearTimeout(timer)
    document.embeds[name].play();
    here=where
    timer=setTimeout("document.location=whereto[here]",1000)
    }
    // -->
    </SCRIPT>

    <SCRIPT LANGUAGE=JavaScript>
    <!--
    timer=""
    whereto1=new Array()
    whereto1[whereto.length]="http://www.yahoo.com"

    function playSound1(name,where){
    clearTimeout(timer)
    document.embeds[name].play();
    here=where
    timer=setTimeout("document.location=whereto1[here]",6000)
    }
    // -->
    </SCRIPT>

    </HEAD>

    <BODY>

    <EMBED SRC="sounds/sound1.wav" autostart=false HIDDEN=TRUE NAME="music1" MASTERSOUND width="128" height="128">
    <EMBED SRC="sounds/sound2.wav" autostart=false HIDDEN=TRUE NAME="music2" MASTERSOUND width="128" height="128">
    <a href="#null" onclick="playSound('music1','0');return false" ><IMG SRC="pictures/pic1.jpg"></a>
    <a href="#null" onclick="playSound('music1','1');return false" ><IMG SRC="pictures/pic2.jpg"></a>
    <a href="#null" onclick="playSound('music1','2');return false" ><IMG SRC="pictures/pic3.jpg"></a>
    <a href="#null" onclick="playSound('music1','3');return false" ><IMG SRC="pictures/pic4.jpg"></a>
    <a href="#null" onclick="playSound('music1','4');return false" ><IMG SRC="pictures/pic5.jpg"></a>
    <a href="#null" onclick="playSound('music1','5');return false" ><IMG SRC="pictures/pic6.jpg"></a>
    <a href="#null" onclick="playSound1('music2','6');return false" ><IMG SRC="pictures/pic7.jpg"></a>

    </BODY>
    </HTML>

  • #2
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    this may seem nit-picky...

    but if you change your "onclick" to "onClick", you might just have an all-round working script...

  • #3
    New Coder
    Join Date
    Jul 2002
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I tried what you said, but it still didn't work. i still get an error in internet explorer 6. are there any other suggestions how i could make this script compatible with all netscape and internet explorer browsers, especially IE6.

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    you didn't mention what error msg is displayed in IE6

    Originally posted by JeStEr
    I tried what you said, but it still didn't work. i still get an error in internet explorer 6. are there any other suggestions how i could make this script compatible with all netscape and internet explorer browsers, especially IE6.

  • #5
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72° W. 48' 57" , 41° N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    i'm surprised that it works in netscape.

    i think you've got a couple of problems. try the following, and let me know how it works:

    Code:
    <HTML> 
    <HEAD> 
    <TITLE>Untitled</TITLE> 
    
    <SCRIPT LANGUAGE=JavaScript><!--
    timer, here, whereto = ["http://www.yahoo.com","http://www.google.com","http://www.huntingground.net","http://www.microsoft.com","http://www.freeserve.co.uk","http://www.yahoo.com"];
    
    function playSound(name,where){ 
        clearTimeout(timer);
        document.embeds[name].play(); 
        here = where;
        timer = setTimeout("window.location = whereto[here]",1000) ;
        }
    //--></SCRIPT>
    
    </HEAD> 
    
    <BODY> 
    
    <EMBED SRC="sounds/sound1.wav" autostart=false HIDDEN=TRUE NAME="music1" MASTERSOUND width="128" height="128"> 
    <EMBED SRC="sounds/sound2.wav" autostart=false HIDDEN=TRUE NAME="music2" MASTERSOUND width="128" height="128"> 
    <a href="javascript:playSound('music1','0'); void 0;"><IMG SRC="pictures/pic1.jpg"></a> 
    <a href="javascript:playSound('music1','1'); void 0;"><IMG SRC="pictures/pic2.jpg"></a> 
    <a href="javascript:playSound('music1','2'); void 0;"><IMG SRC="pictures/pic3.jpg"></a> 
    <a href="javascript:playSound('music1','3'); void 0;"><IMG SRC="pictures/pic4.jpg"></a> 
    <a href="javascript:playSound('music1','4'); void 0;"><IMG SRC="pictures/pic5.jpg"></a> 
    <a href="javascript:playSound('music1','5'); void 0;"><IMG SRC="pictures/pic6.jpg"></a> 
    <a href="javascript:playSound('music2','6'); void 0;"><IMG SRC="pictures/pic7.jpg"></a> 
    
    </BODY> 
    </HTML>
    Last edited by joh6nn; 07-29-2002 at 08:19 AM.
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    to play sound in IE you need <bgsound> tag not <embed> tag.
    then you just set the .src property of the sound object to play it and set to empty to stop.

  • #7
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72° W. 48' 57" , 41° N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    no, ie will take embed. i don't know if netscape will take bgsound, though.
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

  • #8
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    Originally posted by joh6nn
    no, ie will take embed. i don't know if netscape will take bgsound, though.
    http://codingforums.com/showthread.php?threadid=2900

  • #9
    New Coder
    Join Date
    Jul 2002
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    when i used the code above you gave me it wouldn't play the sound or link to the correct websites in IE6 or netscape.

    i'm thinking it's my IE6, but i'm not positive it is, because i tried the first code that i used (the first post) and it worked in IE5.5 on a different computer.

    when i use my code (the first post) the error message that i receive in IE6 is "a runtime error has occured, do you wish to debug?"

    are there any suggestions on how to fix this, remember i need the javascript to be able to work on all netscape and all IE browsers.

  • #10
    New Coder
    Join Date
    Jul 2002
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    maybe is it possible to have the first code (first post) written two times, one specifically for all netscape browsers and one specifically for all IE browsers, would that work?

  • #11
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72° W. 48' 57" , 41° N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    the following code works for me in Internet Explorer. my copy of mozilla complains that "document.embeds[name].play();" is not a method. i'm guessing this means there's a netscape/mozilla specific method to make things play. i don't know what it is. however, the part about changing to the new url still works in mozilla.

    Code:
    <HTML> 
    <HEAD> 
    <TITLE>Untitled</TITLE> 
    
    <SCRIPT LANGUAGE=JavaScript><!--
    var timer = false, here, whereto = ["http://www.yahoo.com","http://www.google.com","http://www.huntingground.net","http://www.microsoft.com","http://www.freeserve.co.uk","http://www.yahoo.com"];
    
    function playSound(name,where){ 
        if (timer != false) {
            clearTimeout(timer);
            }
        document.embeds[name].play(); 
        here = where;
        timer = setTimeout("window.location = whereto[here]",1000);
        }
    //--></SCRIPT>
    
    </HEAD> 
    
    <BODY> 
    
    <EMBED SRC="sounds/sound1.wav" autostart="false" HIDDEN=TRUE NAME="music1" MASTERSOUND width="128" height="128"> 
    <EMBED SRC="sounds/sound2.wav" autostart=false HIDDEN=TRUE NAME="music2" MASTERSOUND width="128" height="128"> 
    <a href="javascript:playSound('music1','0'); void 0;"><IMG SRC="pictures/pic1.jpg" width="10" height="10" alt=""></a>
    <a href="javascript:playSound('music1','1'); void 0;"><IMG SRC="pictures/pic2.jpg" width="10" height="10" alt=""></a>
    <a href="javascript:playSound('music1','2'); void 0;"><IMG SRC="pictures/pic3.jpg" width="10" height="10" alt=""></a>
    <a href="javascript:playSound('music1','3'); void 0;"><IMG SRC="pictures/pic4.jpg" width="10" height="10" alt=""></a>
    <a href="javascript:playSound('music1','4'); void 0;"><IMG SRC="pictures/pic5.jpg" width="10" height="10" alt=""></a>
    <a href="javascript:playSound('music1','5'); void 0;"><IMG SRC="pictures/pic6.jpg" width="10" height="10" alt=""></a>
    <a href="javascript:playSound('music2','6'); void 0;"><IMG SRC="pictures/pic7.jpg" width="10" height="10" alt=""></a> 
    
    </BODY> 
    </HTML>
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

  • #12
    New Coder
    Join Date
    Jul 2002
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks


  •  

    Posting Permissions

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