在HTML中提交进入Javascript的关键字
我想做一个Chrome扩展。。我想要一个选项页面,您可以在其中提交关键字:在HTML中提交进入Javascript的关键字,javascript,html,forms,google-chrome-extension,Javascript,Html,Forms,Google Chrome Extension,我想做一个Chrome扩展。。我想要一个选项页面,您可以在其中提交关键字: <html> <head> <title>Options</title> </head> <body> Keyword:<input id="keyText" name="Keyword" type="text"> <input name="Submit" type="submit" v
<html>
<head>
<title>Options</title>
</head>
<body>
Keyword:<input id="keyText" name="Keyword" type="text">
<input name="Submit" type="submit" value="Submit">
</body>
</html>
选择权
关键词:
这个javascript应该刷新twitter,直到找到一个关键字,然后单击tweet中的链接。
我希望将这个提交的关键字放入java脚本的第一个变量中:
var shoeName = "";
var nikestore = "nikestore";
var closeFlag = "no";
var tFunction = "twitterScan()";
var tweet = new Array();
var tweetName = new Array();
function twitterScan() {
for (var i = 0; i < 4; i++) {
tweetName[i] = document.getElementsByClassName("fullname js-action-profile-name show-popup-with-id")[0].innerHTML;
tweet[i] = document.getElementsByClassName("js-tweet-text")[i].innerHTML;
}
//if (document.getElementsByClassName("fullname js-action-profile-name show-popup-with-id")[0].innerHTML;
if (tweet[0].match(shoeName) == shoeName) {
document.getElementsByClassName("twitter-timeline-link")[0].click();
tFunction = "get outa here";
shoeName = " 4444 4 456 7 8 456 7 345 7 345 345 3 1 1 133s "; //buffer to jump out of interval loop
}
else if (tweet[1].match(shoeName) == shoeName) {
document.getElementsByClassName("twitter-timeline-link")[1].click();
tFunction = "get outa here";
shoeName = " 4444 4 456 7 8 456 7 345 7 345 345 3 1 1 133s "; //buffer to jump out of interval loop
}
else if (tweet[2].match(shoeName) == shoeName) {
document.getElementsByClassName("twitter-timeline-link")[2].click();
tFunction = "get outa here";
shoeName = " 4444 4 456 7 8 456 7 345 7 345 345 3 1 1 133s "; //buffer to jump out of interval loop
}
else if (tweet[3].match(shoeName) == shoeName) {
document.getElementsByClassName("twitter-timeline-link")[3].click();
tFunction = "get outa here";
shoeName = " 4444 4 456 7 8 456 7 345 7 345 345 3 1 1 133s "; //buffer to jump out of interval loop
}
else {
location.reload(true);
}
setTimeout(tFunction, 700);
}
setTimeout(tFunction, 700);
//setInterval("refreshPage()", 3000);
//setTimeout("twitterScan()", 100);
//setInterval(tFunction, 700);
var shoeName=“”;
var nikestore=“nikestore”;
var closeFlag=“否”;
var tFunction=“twitterScan()”;
var tweet=新数组();
var tweetName=新数组();
函数twitterScan(){
对于(变量i=0;i<4;i++){
tweetName[i]=document.getElementsByClassName(“全名js操作配置文件名称显示id为的弹出窗口”)[0]。innerHTML;
tweet[i]=document.getElementsByClassName(“js tweet text”)[i].innerHTML;
}
//if(document.getElementsByClassName(“fullname js action profile name show popup with id”)[0].innerHTML;
if(tweet[0]。匹配(shoeName)==shoeName){
document.getElementsByClassName(“twitter时间线链接”)[0]。单击();
t function=“离开这里”;
shoeName=“4444 4 456 7 8 456 7 345 7 345 345 3 1 133s”//跳出间隔循环的缓冲区
}
else if(tweet[1]。匹配(shoeName)=shoeName){
document.getElementsByClassName(“twitter时间线链接”)[1]。单击();
t function=“离开这里”;
shoeName=“4444 4 456 7 8 456 7 345 7 345 345 3 1 133s”//跳出间隔循环的缓冲区
}
else if(tweet[2]。匹配(shoeName)=shoeName){
document.getElementsByClassName(“twitter时间线链接”)[2]。单击();
t function=“离开这里”;
shoeName=“4444 4 456 7 8 456 7 345 7 345 345 3 1 133s”//跳出间隔循环的缓冲区
}
else if(tweet[3]。匹配(shoeName)==shoeName){
document.getElementsByClassName(“twitter时间线链接”)[3]。单击();
t function=“离开这里”;
shoeName=“4444 4 456 7 8 456 7 345 7 345 345 3 1 133s”//跳出间隔循环的缓冲区
}
否则{
位置。重新加载(true);
}
设置超时(t函数,700);
}
设置超时(t函数,700);
//设置间隔(“刷新页面()”,3000);
//setTimeout(“twitterScan()”,100);
//设置间隔(t功能,700);
HTML
Keyword:<input id="keyText" name="Keyword" type="text">
<input id="submit_button" name="Submit" type="Submit" value="Submit" onClick="javascript: twitterScan();">
关键字:
JS
<script>
var shoeName = '';
function twitterScan() {
shoeName = document.getElementById('keyText').value;
console.log("Iam called " + shoeName);
}
</script>
var shoeName='';
函数twitterScan(){
shoeName=document.getElementById('keyText')。值;
log(“Iam调用”+shoeName);
}
检查
让我知道这是否是您所需要的html发布是否完整?您当前面临的问题是什么?变量数据没有出现还是某些函数出现错误?我希望在html中提交的关键字在java中设置为var shoeNamescript@user2125877:我不确定为什么
document.getElementById('ketText')).val
在你的情况下不起作用,你能创建一个JSIDLE吗?我很困惑,你知道有两个单独的文档,一个是html,另一个是.JS吗?是的,我知道这就是为什么我在回答中添加为单独的,有什么混淆吗?你提供的JS代码加载到你的html页面或其他地方?你是如何调用js的?