document.write('&timestamp') problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bruceturek
    New Member
    • Dec 2008
    • 1

    document.write('&timestamp') problem

    I'm having an issue that I'm sure there is a simple fix for! I'm creating a java script that will dynamically create a URL. In the process I need to include a URL parameter '&timestamp=' followed by an actual timestamp. I noticed that when I use the combination &timestamp under IE 7 the string gets converted to xtamp. This even occurs if I just use document.write( '&timestamp') ; to write the string out. It results in xtamp! Under a firefox browser the string gets represented correctly.

    Any insights would be greatly welcomed!!! Thx
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    I'd recommend using the DOM methods instead of document.write( ). for standard complient browsers this would be (creating the href-attribute)
    Code:
    [I]element[/I].setAttribute("href", "[I]href_value[/I]");
    but IE doesn't fully support that (at least as far as I know), so you need the older DOM methods:
    Code:
    var HR = document.createAttribute("href");
    HR.nodeValue = "[I]href_value[/I]";
    [I]element[/I].setAttributeNode(HR);
    and it's always good practice to escape the ampersand (xhtml parsers will give you an "undefined entity" error, otherwise).

    regards

    Comment

    • clain
      New Member
      • Feb 2007
      • 79

      #3
      yeah... thats correct... IE renders all the time related DOM objects in old fashion. it needs to update the scripting engine. unfortunately they do not do so...

      only alternate idea is to have a custom made time stamp.. its a hard task though.. there no other alternative (at least as far as i know)

      Comment

      Working...