DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: dynamic created javascript works in ie and firefox but not for chrome

  1. #1
    Join Date
    Oct 2008

    dynamic created javascript works in ie and firefox but not for chrome

    Hi there,

    I am submitting a form without runat attribute and post method. I use ClientScriptManager to create dynamically this form (dynamic html) and with submit() method of javascript I submit it. When I choose an element from a drop down list, I create this javascript function that contructs dynamic javascript and html, and later when an button is clicked, this javascript function, called FireNow(), is called.
    So far, this works in IE 8 and Firefox 3.5 under Windows 7, but doesn't work in Chrome 4.1 in Windows 7.
    I am sending the source code:

    Dim script As String = "<script language='javascript'>function FireNow() {document.body.innerHTML += ""<form id='dynForm' action='" + <an url>' method='post'>"
    script += "<input type='hidden' name=a' value='a'>"
    script += "<input type='hidden' name='b' value='b'>"
    script += "<input type='hidden' name='c' value='c'>"
    script += "<input type='hidden' name='z' value='z'>"
    script += "</form>"";"
    script += "document.forms['dynForm'].submit();}</script>"
    Dim csm As ClientScriptManager = Me.ClientScript
    csm.RegisterClientScriptBlock(Me.GetType(), "PostToDF", script)
    Me.Login.OnClientClick = "return FireNow();"

    this code if executed when an user selects an item from a drop down list. next, this user will click on an button called Login.
    If I execute this web page in IE 8 or Firefox 3.5 and select an item from this drop down list, this page posts back, i look at html source and i can see dynamic javascript generated by source code i am sending. next, when user clicks on Login button, javascript function called FireNow() is called, and everything goes as planned.
    With chrome 4.1 and after selecting an item from a drop down list, this page posts back, but I dont see anywhere in its html code this dynamic javascript I created. however, i can see that Login button has > onclick="return FireNow();" <

    So, what is happening is that i can write dynamically created javascript with for IE and firefox, but this doesn't happen in chrome 4.1 (i only have tested this with windows 7).

    Is there a patch or workaround to make this page to write dynamic javascript in chrome 4.1 just like it does in ie 8 and firefox 3.5?

    To give hints, chrome 4.1 will not throw an error once this page posts back after selecting an item from a drop down list, which writes this dynamic javascript. it looks very much that chrome decides to do not write this dynamic javascript after post back on purpose.

    Any help, hints, clues, tips, etc will be enormously appreciated. my boss thinks that if i cover ie and firefox altogether i did most of my work, but i think chrome is currently the second most used browser, so this is important.

    best regards,

    tonci korsano

  2. #2
    Join Date
    Oct 2008

    chrome incognito mode

    it wasn't working on chrome only in my laptop because sometimes i surf the internet in incognito mode. some other settings i have, which are not chrome default settings, don't let my script work even if i don't surf as incognito. thus, my script will work in chrome with default settings in windows 7, windows vista and mac os. my script my work in other opeating systems as well.

    best regards,


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center