dv = document.createElement('div'); // create dynamically div tag
dv.setAttribute('id', "lyr1"); // give id to it
dv.className = "top"; // set the style classname
// set the inner styling of the div tag
dv.style.position = "absolute";
// set the html content inside the div tag
dv.innerHTML = "<input id='serialize01' type='button' value='Serialize' onClick='objSerializeDOM.createXML(),objSerializeDOM.disableSerialize()'/>";
// finally add the div id to your form
document.body.insertBefore(dv, document.body.firstChild);
I am using this javascript code to put a button on every page of my domain.I achieve this using GreaseMonkey4IE plugin for IE.But the problem now is that it’s not working for the web pages having frames.
file1.html
<html>
<head>
<title></title>
</head>
<frameset rows="50%,50%">
<frame src="friends.html">
</frameset>
</html>
main.html
<html>
<head>
<title>Joe and Jackie's friends</title>
</head>
<frameset cols="25%,75%">
<frame src="file1.html">
</frameset>
</html>
friends.html
<html>
<head>
<title></title>
</head>
<body bgcolor="#ccffff">
Joe's friend<br>
<b>Bill</b>
</body>
</html>
When I deploy the above files using tomcat, the button is not showing up.
To deploy :
1.I copied all three html files above and pasted’em inside a fodler named say folder1.
2.Copied folder1 inside webapps folder in tomcat directory.
3.Registered my .js file for domain(i.e,) localhost in GreaseMonkey4IE
4.Hit the URL from browser(IE8) i.e, http://localhost:8080/file1.html (button shows)
5.Hit the URL from browser i.e, http://localhost:8080/main.html (button does not show up.)
I guess whenever there are frames in the web page, it seems the button appended on the web-page get overwritten by the frame . 🙁
Any idea???
Is it by any way possible to get my button displayed ??
Thanks a lot.
I tried the above code and it worked for me.
This time I created a new frame and then put my button on it and finally added the frame as the first frame.
The code provided in the question will work only in case where the web pages don’t have any frame.