使我的书签跨浏览器
这是我之前与此问题相关的问题: 阅读源代码来自 IE/Chrome/Firefox 中选项卡的代码。
我不太擅长 JavaScript。我能够编写一些可以在 Firefox 中运行但不能在 IE 或 Chrome 中运行的东西。有人可以帮我让它在 IE、Firefox 和 Chrome 下运行吗?我正在运行 IE 8、Firefox 3.6.13 和 Chrome 6。
我的总体计划是进入显示密码的页面,突出显示密码,单击书签工具栏上的书签按钮,正确的解码密码将出现在屏幕上的文本框。
javascript:(
function()
{
var selectedText = document.getSelection();
if (selectedText == "")
{
alert('Please select the pass code before clicking the button.');
return;
}
var map = [];
map["0"] = "Z";
map["1"] = "D";
map["2"] = "H";
map["3"] = "K";
map["4"] = "N";
map["5"] = "E";
map["6"] = "H";
map["7"] = "S";
map["8"] = "U";
map["9"] = "W";
map["A"] = "M";
map["B"] = "Q";
map["C"] = "H";
map["D"] = "A";
map["E"] = "P";
map["F"] = "O";
var output = "";
for (var i = 0; i < selectedText.length; i++)
{
output = output + map[selectedText[i]];
}
var frmObject = document.forms[0];
var frmElement = frmObject.elements["txtPassCode"];
frmElement.value = output;
}
)();
Here is my previous question that is related to this question: Read source code from tabs in IE/Chrome/Firefox.
I'm not very good at Javascript. I was able to write something that works in Firefox but not in IE or Chrome. Can someone help me get this running under IE, Firefox and Chrome? I am running IE 8, Firefox 3.6.13 and Chrome 6.
My general plan is to get to the page where the passcode is presented, highlight the pass code, click the bookmarklet button on my bookmarks toolbar and the correct decoded passkey will appear in the textbox on the screen.
javascript:(
function()
{
var selectedText = document.getSelection();
if (selectedText == "")
{
alert('Please select the pass code before clicking the button.');
return;
}
var map = [];
map["0"] = "Z";
map["1"] = "D";
map["2"] = "H";
map["3"] = "K";
map["4"] = "N";
map["5"] = "E";
map["6"] = "H";
map["7"] = "S";
map["8"] = "U";
map["9"] = "W";
map["A"] = "M";
map["B"] = "Q";
map["C"] = "H";
map["D"] = "A";
map["E"] = "P";
map["F"] = "O";
var output = "";
for (var i = 0; i < selectedText.length; i++)
{
output = output + map[selectedText[i]];
}
var frmObject = document.forms[0];
var frmElement = frmObject.elements["txtPassCode"];
frmElement.value = output;
}
)();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
来源:http://help.dottoro.com/ljcvonpc.php
source : http://help.dottoro.com/ljcvonpc.php
尝试将代码长度优化到 500 个字符以下,目前超过 900 个字符。
Try to optimize your code length to under 500 character, current it's more then 900.