框架覆盖按钮?
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);
我正在使用这段 javascript 代码在我的域的每个页面上放置一个按钮。我使用 IE 的 GreaseMonkey4IE 插件来实现此目的。但现在的问题是它不适用于具有框架的网页。< br>
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>
当我使用 tomcat 部署上述文件时,按钮没有显示。 部署:
1.我复制了上面的所有三个 html 文件并将它们粘贴到名为“folder1”的文件夹中。
2.将文件夹1复制到tomcat目录中的webapps文件夹中。
3.在 GreaseMonkey4IE 中为域(即)本地主机注册我的 .js 文件
4.从浏览器(IE8)点击 URL,即 http://localhost:8080/ file1.html(按钮显示)
5.从浏览器中点击 URL,即 http://localhost:8080/main.html (按钮确实没有出现。)
我想只要网页中有框架,似乎附加在网页上的按钮就会被框架覆盖。 :(
有什么想法吗???
有什么办法可以让我的按钮显示出来吗?
多谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您可以使用 php,您可能会发现通过调用 php include 脚本添加全局按钮要容易得多。我从使用 JavaScript 切换到使用 php,发现它解决了许多浏览器问题,因为按钮是在页面渲染期间添加的,而不是由用户端的浏览器添加的。
例如
,然后将原始 html 放入名为“demo.php”的文件中,然后将其上传到同一文件中,看看它是否有效:)
祝你好运!
If you can use php you may find it much easier to add in a global button by calling a php include script. I switched from using JavaScript to php and found it cleaned up allot of browsers problems because the buttons are added during page render instead of by the browsers on the users end.
example
then just put your raw html in a file called "demo.php" then upload it in the same file and see if it works :)
good luck!
我尝试了上面的代码,它对我有用。
这次我创建了一个新框架,然后将按钮放在上面,最后将该框架添加为第一框架。
问题中提供的代码仅适用如果网页没有任何框架。
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.