SitePoint Sponsor

User Tag List

Results 1 to 12 of 12

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Dec 2007
    Location
    NB, Canada
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    document.getElementById Problem in IE

    Hi there.
    I'm having an unexpected issue and I need some help!

    I'm passing a value from one page1 to page2 using a query String. I have successfully done this and it works with Firefox 3.0. But not with IE.

    My function accepting the value:
    Code:
    function MP3Redirect() {
    	window.location.href = "?" + encodeURIComponent(window.location.href);
    	
    }
    On page2, I have the following in the HEAD tag:

    Code:
    <script type="text/javascript">
    function loadVarIntoPage() {
    	var mp3_track = decodeURIComponent(window.location.search.substr(1));
    	document.getElementById('qt_player').src = mp3_track;
    	
    }
    window.onload = loadVarIntoPage;
    </script>
    And finally, In the BODY of page2, I have the following:

    Code:
    <embed id="qt_player" src="" .......>
    In Firefox, the src query value gets passed and the quicktime player works, however it IE, it does not get passed. Any ideas why this would be happening???

  2. #2
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do any errors show up in IE?
    Have you tried alerting mp3_track?
    James Padolsey
    末末末末末末末末末末末末末末末末末末末
    Awesome JavaScript Zoomer (demo here)
    'Ajaxy' - Ajax integration solution (demo here)

  3. #3
    SitePoint Member
    Join Date
    Dec 2007
    Location
    NB, Canada
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi JimmyP, yes indeed. mp3_track returns the path to the MP3 track I need.
    No errors in IE as far as I can tell.

    The fact that it works in Firefox tells me the code is correct but something in IE is malfunctioning.

    Any ideas or directions to try? I'm fresh out.

  4. #4
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I assume it works perfectly in IE when you hard-code the SRC?
    James Padolsey
    末末末末末末末末末末末末末末末末末末末
    Awesome JavaScript Zoomer (demo here)
    'Ajaxy' - Ajax integration solution (demo here)

  5. #5
    SitePoint Member
    Join Date
    Dec 2007
    Location
    NB, Canada
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It does yes. I tried this to make sure it works.
    When isolating the problem, it looks like
    Code:
    document.getElementById('qt_player').src = mp3_track;
    Is not properly setting the SRC.

  6. #6
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What about if you use setAttribute?
    James Padolsey
    末末末末末末末末末末末末末末末末末末末
    Awesome JavaScript Zoomer (demo here)
    'Ajaxy' - Ajax integration solution (demo here)

  7. #7
    SitePoint Addict
    Join Date
    Dec 2007
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Know that getElementById in IE return elements with both a matching ID OR NAME.

    Make sure you don't have an element with a name attribute value of qt_player.
    mmj

  8. #8
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    100 Post(s)
    Tagged
    4 Thread(s)
    If you could please provide a link to a test page, we will be able to help you a lot faster.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  9. #9
    SitePoint Member
    Join Date
    Dec 2007
    Location
    NB, Canada
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I prepared a trimmed down sample. Please check out the link.
    http://jmedia.ca/test/page1.html

    Try it with Firefox and then IE. Only works with Fox.

  10. #10
    SitePoint Addict
    Join Date
    Dec 2007
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Its not playing but the javascript is working fine.

    Maybe ie doesn't like the embed tag setup like that.
    mmj

  11. #11
    SitePoint Member
    Join Date
    Dec 2007
    Location
    NB, Canada
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, I have yet to resolve this issue and was hoping someone could have a look at my test link: http://jmedia.ca/test/page1.html

    I'm quite new to JS, so if you have a solution, please go easy on me!

  12. #12
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    100 Post(s)
    Tagged
    4 Thread(s)
    The alert is showing the name of the mp3 in both Firefox 2 and IE 7.
    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
  •