Forum Moderators: open

Message Too Old, No Replies

Replacing innerHTML breaks Google search buttons

In Firefox on the Google results page

         

Pipeline

11:40 pm on Mar 13, 2007 (gmt 0)

10+ Year Member



Hi

I am working on some JavaScript for Firefox that builds a string to replace the innerHTML of a visited webpage. I have noticed that this seems to disable the search buttons on Google's results page (but not on the Google homepage). Also, pressing enter after typing in a search term has no effect. I have yet to come across another webpage that has the same symptoms.

I even tried just replacing the innerHTML with itself to make sure that I'm not altering anything at all but even this breaks the Google results page. Here is the code I used for this:

var win = document.commandDispatcher.focusedWindow;
var innerHTML = win.document.body.innerHTML;
win.document.body.innerHTML = innerHTML;

The resulting document is identical to the original. The page even looks the same in Firefox. Only the search buttons don't work (and the enter key to submit search terms).

Has anyone else had similar experience? Any ideas on what is causing it? Suggestions on how to work around?

Thanks!

RonPK

12:16 pm on Mar 15, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Forms usually don't do much when appended to an element using the element's
innerHTML
property. Try using the DOM and methods such as
createElement()
and
appendChild()
.

And welcome to WebmasterWorld!

StupidScript

6:07 pm on Mar 15, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's possible you are running into a security provision in Javascript and/or your browser(s) whereby using innerHTML to echo content from a different domain is disabling some of the functionality of the echo'd page. Kind of anti-phishing protection ... I know I would appreciate such protection if I went to a page that displayed, say, Google without it being hosted on the Google servers.