www.webdeveloper.com
Results 1 to 4 of 4

Thread: Why can't these javascript codes working on non-IE browsers?

  1. #1
    Join Date
    Jul 2012
    Posts
    3

    Lightbulb Why can't these javascript codes working on non-IE browsers?

    var current_point="url(images/step_points.png) no-repeat 0px 0px";

    function init(){
    show_step('1');
    oCurrent('0');
    }

    function show_step(i){
    var img=document.getElementById("s_img");
    switch(i) {
    case '1':
    img.style.backgroundImage="url(images/zhua.png)";
    img.style.right="0";
    document.getElementById("steps_content").src="step1.htm";

    getEle('step1_big').style.display="";
    getEle('step2_big').style.display="none";
    getEle('step3_big').style.display="none";
    getEle('step4_big').style.display="none";

    getEle('step1_cpoint').style.background=current_point;
    getEle('step2_cpoint').style.background="";
    getEle('step3_cpoint').style.background="";
    getEle('step4_cpoint').style.background="";

    getEle('step1_div').style.visibility="hidden";
    getEle('step2_div').style.visibility="visible";
    getEle('step3_div').style.visibility="visible";
    getEle('step4_div').style.visibility="visible";
    break;
    case '2':
    img.style.backgroundImage="url(images/xuan.png)";
    img.style.right="0";
    document.getElementById("steps_content").src="step2.htm";
    getEle('step2_big').style.display="";
    getEle('step1_big').style.display="none";
    getEle('step3_big').style.display="none";
    getEle('step4_big').style.display="none";

    getEle('step2_cpoint').style.background=current_point;
    getEle('step1_cpoint').style.background="";
    getEle('step3_cpoint').style.background="";
    getEle('step4_cpoint').style.background="";

    getEle('step2_div').style.visibility="hidden";
    getEle('step1_div').style.visibility="visible";
    getEle('step3_div').style.visibility="visible";
    getEle('step4_div').style.visibility="visible";
    break;
    case '3':
    img.style.backgroundImage="url(images/xi.png)";
    img.style.right="610px";
    document.getElementById("steps_content").src="step3.htm";
    getEle('step3_big').style.display="";
    getEle('step1_big').style.display="none";
    getEle('step2_big').style.display="none";
    getEle('step4_big').style.display="none";

    getEle('step3_cpoint').style.background=current_point;
    getEle('step1_cpoint').style.background="";
    getEle('step2_cpoint').style.background="";
    getEle('step4_cpoint').style.background="";

    getEle('step3_div').style.visibility="hidden";
    getEle('step1_div').style.visibility="visible";
    getEle('step2_div').style.visibility="visible";
    getEle('step4_div').style.visibility="visible";
    break;
    case '4':
    img.style.backgroundImage="url(images/ce.png)";
    img.style.right="610px";
    document.getElementById("steps_content").src="step4.htm";
    getEle('step4_big').style.display="";
    getEle('step1_big').style.display="none";
    getEle('step2_big').style.display="none";
    getEle('step3_big').style.display="none";

    getEle('step4_cpoint').style.background=current_point;
    getEle('step1_cpoint').style.background="";
    getEle('step2_cpoint').style.background="";
    getEle('step3_cpoint').style.background="";

    getEle('step4_div').style.visibility="hidden";
    getEle('step1_div').style.visibility="visible";
    getEle('step2_div').style.visibility="visible";
    getEle('step3_div').style.visibility="visible";

    }
    }

    // Those codes can run on IE, but others. I can't figure out the reason. I will really appreciate helping me solve the problem. Thanks!

  2. #2
    Join Date
    Feb 2011
    Posts
    231
    Hi,
    I think that getEle('...') is a syntax error, and it should be: document.getElementById instead of getEle .

  3. #3
    Join Date
    Jul 2012
    Posts
    3

    Additional

    Quote Originally Posted by MarPlo View Post
    Hi,
    I think that getEle('...') is a syntax error, and it should be: document.getElementById instead of getEle .
    function getEle(id1){
    var frame1='steps_btn';
    var ele=document.frames[frame1].document.getElementById(id1);
    return ele;
    }

  4. #4
    Join Date
    Feb 2011
    Posts
    231
    Hi,
    Try replace:
    var ele=document.frames[frame1].document.getElementById(id1);
    With this:
    var ele=document.getElementById(iframe_id).contentWindow.document.getElementById(id1);
    - And use an ID in the <iframe>
    Last edited by MarPlo; 07-24-2012 at 11:43 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles