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 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jul 2003
    Posts
    600
    Thanks
    17
    Thanked 0 Times in 0 Posts

    sIFR Working in IE but not FF (using JS)

    Hey All,

    I've got the following code working in IE, but not FF. It's tied to the sIFR method, but that isn't the problem here. It's because of the script tags. What's the best way to encode the following?

    <h3><script language="javascript">document.write("NAME" + varName);</script></h3>

    Any suggestions would be much appreciated.

    Thanks.

  • #2
    Regular Coder
    Join Date
    Jul 2005
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm not sure because you gave little to go on but is this what you're trying to do?
    Code:
    <script type="text/javascript">
    var varName = " test";
    document.write('<h3><script language="javascript">document.write("NAME" + varName);<' + '/script></h3>');
    </script>
    If so the reason it wasn't working is because the browser sees the </script> and thinks you forgot to terminate a string and it's at the end of the script. When you break it up into "<" and the "/script>" the browser doesn't recognize it as a closing tag.

  • #3
    Regular Coder
    Join Date
    Jul 2003
    Posts
    600
    Thanks
    17
    Thanked 0 Times in 0 Posts
    Yep, that's exactly what I'm trying to do. However I tried what you listed and it didn't work . .

    Hmm ..

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    I don't get the poit... It works in FF as well

    <h3><script type="text/javascript">document.write("NAME"+varName);</script></h3>

    but the variable varName must be:
    1. a global
    2. set before runing the code
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #5
    Regular Coder
    Join Date
    Jul 2003
    Posts
    600
    Thanks
    17
    Thanked 0 Times in 0 Posts
    It is set up above ..

    <script language="javascript">
    var varName = "";
    varName = getParameter('vehicleName');
    </script>

    That works and displays the actual varName value in IE. However in FF, it displays the actual JS "doc write .. " code ..

  • #6
    Regular Coder
    Join Date
    Jul 2005
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The code I posted works in Firefox and IE although there's not much point to it unless you're calling it in a loop or something.

    getParameter() isn't a standard JavaScript function. Are you sure it is working in Firefox? Do you get any errors or warnings in the JavaScript console?

    Maybe if you can post your whole page we can get a better idea of what is going wrong.


  •  

    Posting Permissions

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