innerHTML Javascript Issues. can anyone help?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pratik Patel

    innerHTML Javascript Issues. can anyone help?

    Hello,

    I used innerHTML to assign HTML content. but in my HTML page content
    have also some javascript function and it will run when page load. bu
    when HTML code assgin thru innerHTML then this javascript is not
    working.

    e.g.

    html content:
    ............... .......
    <html>
    <body>
    <table>
    <tr><td>
    Some content here.
    </td></tr>
    </table>
    <script language="javas cript">
    alert("hi");
    </script>
    </body>
    </html>

    I am assign this html page in innerHTML content

    document.getEle mentById('div1' ).innerHTML="<h tml><body><tabl e><tr><td>Some
    content here.</td></tr></table><script
    language="javas cript">alert("h i");</script></body></html>";

    when i used direct html page it's given alert message. but when i used
    theu innerHTML then it's not given alert message.

    how i can execute javascript in innerHTML?can anyone help?

    Regards
    Pratik Patel

  • Rami Elomaa

    #2
    Re: innerHTML Javascript Issues. can anyone help?

    Pratik Patel kirjoitti:
    how i can execute javascript in innerHTML?can anyone help?
    Wrong group dude. This is php, you wanted javascript. Better luck next time.

    --
    Rami.Elomaa@gma il.com

    "Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
    usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze

    Comment

    • Pratik Patel

      #3
      Re: innerHTML Javascript Issues. can anyone help?

      On Jun 20, 12:02 pm, Rami Elomaa <rami.elo...@gm ail.comwrote:
      Pratik Patel kirjoitti:
      >
      how i can execute javascript in innerHTML?can anyone help?
      >
      Wrong group dude. This is php, you wanted javascript. Better luck next time.
      >
      --
      Rami.Elo...@gma il.com
      >
      "Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
      usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze
      I was post same topic in javascript group also. but PHP people also
      known javascript. and I have this kind of issue in AJAX. so i post
      this topic at here.

      Comment

      • petersprc

        #4
        Re: innerHTML Javascript Issues. can anyone help?

        It would be easier to separate the text and the script and call eval
        on the script part.

        Problem is the browser can't be counted on to evaluate your embedded
        scripts. Here's a workaround:



        On Jun 20, 2:10 am, Pratik Patel <anay.pra...@gm ail.comwrote:
        Hello,
        >
        I used innerHTML to assign HTML content. but in my HTML page content
        have also some javascript function and it will run when page load. bu
        when HTML code assgin thru innerHTML then this javascript is not
        working.
        >
        e.g.
        >
        html content:
        ............... ......
        <html>
        <body>
        <table>
        <tr><td>
        Some content here.
        </td></tr>
        </table>
        <script language="javas cript">
        alert("hi");
        </script>
        </body>
        </html>
        >
        I am assign this html page in innerHTML content
        >
        document.getEle mentById('div1' ).innerHTML="<h tml><body><tabl e><tr><td>Some
        content here.</td></tr></table><script
        language="javas cript">alert("h i");</script></body></html>";
        >
        when i used direct html page it's given alert message. but when i used
        theu innerHTML then it's not given alert message.
        >
        how i can execute javascript in innerHTML?can anyone help?
        >
        Regards
        Pratik Patel

        Comment

        • Jerry Stuckle

          #5
          Re: innerHTML Javascript Issues. can anyone help?

          Pratik Patel wrote:
          On Jun 20, 12:02 pm, Rami Elomaa <rami.elo...@gm ail.comwrote:
          >Pratik Patel kirjoitti:
          >>
          >>how i can execute javascript in innerHTML?can anyone help?
          >Wrong group dude. This is php, you wanted javascript. Better luck next time.
          >>
          >--
          >Rami.Elo...@gm ail.com
          >>
          >"Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
          >usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze
          >
          I was post same topic in javascript group also. but PHP people also
          known javascript. and I have this kind of issue in AJAX. so i post
          this topic at here.
          >
          And the people who know javascript frequent the javascript newsgroups, also.

          Please use the appropriate newsgroup. This is not it.

          --
          =============== ===
          Remove the "x" from my email address
          Jerry Stuckle
          JDS Computer Training Corp.
          jstucklex@attgl obal.net
          =============== ===

          Comment

          • Toby A Inkster

            #6
            Re: innerHTML Javascript Issues. can anyone help?

            Pratik Patel wrote:
            I was post same topic in javascript group also. but PHP people also
            known javascript. and I have this kind of issue in AJAX. so i post
            this topic at here.
            Some PHP people speak French too, but this isn't the best group to turn to
            when you want something translated for you.

            --
            Toby A Inkster BSc (Hons) ARCS
            [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
            [OS: Linux 2.6.12-12mdksmp, up 3 days, 12:31.]

            A New Look for TobyInkster.co. uk

            Comment

            Working...