提交进入Javascript的HTML中的关键字 [英] Submitting a Keyword in HTML that goes into Javascript

查看:142
本文介绍了提交进入Javascript的HTML中的关键字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 < p>< p> HTML> 
< head>
< title>选项< / title>
< / head>
< body>
关键字:< input id =keyTextname =Keywordtype =text>
< input name =Submittype =submitvalue =Submit>
< / body>
< / html>

这个javascript应该会刷新twitter,直到找到关键字,然后点击tweet中的链接。
我想把这个提交的关键字放到第一个var的java脚本中:

  var shoeName = ; 
var nikestore =nikestore;
var closeFlag =no;
var tFunction =twitterScan();
var tweet = new Array();
var tweetName = new Array();

函数twitterScan(){

for(var i = 0; i <4; i ++){
tweetName [i] = document.getElementsByClassName( fullname js-action-profile-name show-popup-id-id)[0] .innerHTML;
tweet [i] = document.getElementsByClassName(js-tweet-text)[i] .innerHTML;



$ b // if(document.getElementsByClassName(fullname js-action-profile-name show-popup-id-id)[0] .innerHTML;
$ b $ 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; //缓冲区跳出区间循环

}

else if(tweet [1] .match(shoeName)== shoeName){
document.getElementsByClassName(twitter-timeline-link)[1]。点击();
tFunction =get outa here;
shoeName =4444 4 456 7 8 456 7 345 7 345 345 3 1 1 133s; //缓冲区跳出间隔循环



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 ou t间隔循环

}


else if(tweet [3] .match(shoeName)== shoeName){
document.getElementsByClassName( 推 - 时间轴的链接)[3]。点击();
tFunction =在这里取得;
shoeName =4444 4 456 7 8 456 7 345 7 345 345 3 1 1 133s; //缓冲区跳出间隔循环

}


else {
location.reload(true);
}

setTimeout(tFunction,700);


}

setTimeout(tFunction,700);

// setInterval(refreshPage(),3000);
// setTimeout(twitterScan(),100);
// setInterval(tFunction,700);


解决方案

HTML

 关键字:< input id =keyTextname =Keywordtype =text> 
< input id =submit_buttonname =Submittype =Submitvalue =SubmitonClick =javascript:twitterScan();>

JS

 <脚本> 
var shoeName ='';
函数twitterScan(){
shoeName = document.getElementById('keyText')。value;
console.log(Iam called+ shoeName);
}
< / script>

检查 http://jsfiddle.net/raunakkathuria/5FDT3/



让我知道这是你需要的吗


I am looking to make a Chrome extension.. I want an Options Page where you submit a keyword:

<html>
 <head>
    <title>Options</title>
 </head>
 <body>
    Keyword:<input id="keyText" name="Keyword" type="text">
            <input name="Submit" type="submit" value="Submit">
 </body>
</html>

This javascript is supposed to refresh twitter until it find a keyword then clicks on the link in the tweet. I want this submitted keyword to be put in to a java script into the first var:

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);

解决方案

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>

Check http://jsfiddle.net/raunakkathuria/5FDT3/

Let me know if this is what you need

这篇关于提交进入Javascript的HTML中的关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆