我所在的网站有很多聊天室,可以通过下拉菜单访问。问题是下拉菜单是通过 VBScript 生成的,而按钮本身是 Javascript。我使用 Internet Explorer 没有问题,但我的一个 friend 确实需要使用这些房间,但不能,因为她使用的是 Mac。我正在尝试创建一个 Greasemonkey 脚本,该脚本将在页面上的其他位置创建这些按钮,以便她实际上可以单击它们,但我根本没有使用 Greasemonkey 或 Javascript 的经验。
当我右键单击 IE 中的按钮并选择“属性”时,这是它给我的代码。我希望这就是您需要的帮助,如果没有,请告诉我,我会尽力满足您的需求。
javascript:OpenWindow('/Portal/ChatTransfer.aspx?
chatroom=ATTNesting1&url=https://chat02.arise.com/chat/
','','width=800px,height=600px,status=no,menubar=yes,
scrollbars=yes,titlebar=no,resizable=yes,toolbar=no,location=no');
最佳答案
简而言之...
// create button
var btn = document.createElement( 'input' );
with( btn ) {
setAttribute( 'onclick', 'alert( "you clicked me!" )' );
setAttribute( 'value', 'click me!' );
setAttribute( 'type', 'button' );
}
// append at end
document.getElementsByTagName( 'body' )[ 0 ].appendChild( btn );
这应该在页面末尾添加一个按钮;当然,您必须将 onclick 属性中的 alert()
替换为您想要的 OpenWindow()
函数调用。我想你必须用 unsafeWindow.OpenWindow()
来解决它。
关于javascript - 尝试使用 Greasemonkey 创建一个可以运行 Javascript 的按钮。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6614105/