Dynamically insert javascript statements

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • newlearner
    New Member
    • May 2007
    • 67

    Dynamically insert javascript statements

    Hi,
    Is There any way to insert a jascript statements into a script tag which is created dynamically.

    i.e like ("tagName").inn erHTML = string. Is there any way for the script tag.


    Thaks in advance for your reply.
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    hi ...

    i think it should be possible, you may set the innerHTML of every document-node ... but its a really strange thing ... for what reason you want to do that?

    kind regards ...

    Comment

    • epots9
      Recognized Expert Top Contributor
      • May 2007
      • 1352

      #3
      i think i would be something along these lines:
      [CODE=javascript]
      var link = document.create Element('a');
      link.setAttribu te('onclick', 'function()');
      [/CODE]

      good luck

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        yep ... something that makes sense ... that assigns an event-handling to a document node ... but i'm still wondering what might be the purpose of setting the innerHTML of a dynamically created script-tag? may be i misunderstood the question ... but it might be to create an entire new document through javascript? ...

        Comment

        • epots9
          Recognized Expert Top Contributor
          • May 2007
          • 1352

          #5
          when i read it, i thought it was asking for the ablitly to add attributes to dynamically created elements.

          Comment

          • gits
            Recognized Expert Moderator Expert
            • May 2007
            • 5390

            #6
            that might be ... may be i was confused by the term 'script'-tag ;) ...

            Comment

            • newlearner
              New Member
              • May 2007
              • 67

              #7
              Originally posted by gits
              that might be ... may be i was confused by the term 'script'-tag ;) ...
              hi,
              epots9 was right. I need to insert a block of stmts into the created tag.

              It works well with .innerHTML

              I need one more info:
              As i was googling i found in w3.org

              it says node.data = the srting etc.... OR node.data gives the text or data inside the node.

              I tried that but it dosent work any suggestions.

              thanks in advance for your reply.
              ----- Looking Forward

              Comment

              Working...