Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/427.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript bookmarklet,href中断?_Javascript_Jquery_Bookmarklet - Fatal编程技术网

Javascript bookmarklet,href中断?

Javascript bookmarklet,href中断?,javascript,jquery,bookmarklet,Javascript,Jquery,Bookmarklet,我为此烦恼了很长一段时间,我真的希望有人知道这个问题,并找到解决办法 我正在生成一个bookmarklet,如果我在MYSQL和PHP上磨了这么多天之后可以这么说的话,它工作得非常完美 < P>为例,请考虑生成此书签。< /P> javascript:(function(){ a=document.createElement('script'); a.setAttribute('src','//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.m

我为此烦恼了很长一段时间,我真的希望有人知道这个问题,并找到解决办法

我正在生成一个bookmarklet,如果我在MYSQL和PHP上磨了这么多天之后可以这么说的话,它工作得非常完美

< P>为例,请考虑生成此书签。< /P>
javascript:(function(){ a=document.createElement('script'); a.setAttribute('src','//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js'); document.body.appendChild(a); data='[["#txtapplicantlname","agrawal","text"],["#txtapplicantfname","aayush","text"],["#txtfather","Ranjan","text"],["#txtmother","Neelam","text"],["#txtPincode","452010","text"],["#txtPhone","2147483647","text"],["#txtEmail","aayush@mail.com","text"],["#rdosex_0,#rdosex_1","1","radio"]]'; for(a=$.parseJSON(data),b=a.length-1;0<=b;b--){ c=a[b]; if (c[2] =='text') { $(c[0]).val(c[1]); } else if (c[2] == 'radio'){ rdata = c[0].split(','); rnum = c[1] - 1; select = rdata[rnum]; $(select).attr('checked', true); } } })();

javascript:(function(){a=document.createElement('script');a.setAttribute('src'),'//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js');document.body.appendChild(a);data='[[“#txtapplicantlname”,“agrawal”,“text”],[“#txtapplicntfName”,“aayus”,“text”],[“aayus”,“text”],[“#txtfather”,“Ranjan”,“text”],[“text”],[“text”,“452010”、“text”]、[“txtPhone”、“2147483647”、“text”]、[“txtMail”、”aayush@mail.com“,“text”],[“#rdosex_0,#rdosex_1”,“1”,“radio”]];for(a=$.parseJSON(data),b=a.length-1;0当您将其作为超链接插入时,其中断的原因是需要对某些字符(尤其是空格、
'
)进行编码

有关更多信息,请参阅。

请使用

document.getElementsByTagName('head').item(0).appendChild(a);
而不是你用的

document.body.appendChild(a); 

我希望它能很好地工作。

我不明白你的意思?我检查了url,我不明白。你能详细说明一下,并可能就我如何处理这个问题提出建议吗?我尝试了urlencode,但没有真正的帮助。在PHP中,使用该函数对bookmarklet进行编码。确保只对
javascri之后的部分进行编码pt:
尽管如此。
<span class='span6'>Please drag the following button to your bookmarks bar! <br>javascript:(function(){ a=document.createElement('script'); a.setAttribute('src','//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js'); document.body.appendChild(a); data='[["#txtapplicantlname","agrawal","text"],["#txtapplicantfname","aayush","text"],["#txtfather","Ranjan","text"],["#txtmother","Neelam","text"],["#txtPincode","452010","text"],["#txtPhone","2147483647","text"],["#txtEmail","aayush@mail.com","text"],["#rdosex_0,#rdosex_1","1","radio"]]'; for(a=$.parseJSON(data),b=a.length-1;0<=b;b--){ c=a[b]; if (c[2] =='text') { $(c[0]).val(c[1]); } else if (c[2] == 'radio'){ rdata = c[0].split(','); rnum = c[1] - 1; select = rdata[rnum]; $(select).attr('checked', true); } } })();<a href='javascript:(function(){ a=document.createElement('script'); a.setAttribute('src','//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js'); document.body.appendChild(a); data='[[&quot;#txtapplicantlname&quot;,&quot;agrawal&quot;,&quot;text&quot;],[&quot;#txtapplicantfname&quot;,&quot;aayush&quot;,&quot;text&quot;],[&quot;#txtfather&quot;,&quot;Ranjan&quot;,&quot;text&quot;],[&quot;#txtmother&quot;,&quot;Neelam&quot;,&quot;text&quot;],[&quot;#txtPincode&quot;,&quot;452010&quot;,&quot;text&quot;],[&quot;#txtPhone&quot;,&quot;2147483647&quot;,&quot;text&quot;],[&quot;#txtEmail&quot;,&quot;aayush@mail.com&quot;,&quot;text&quot;],[&quot;#rdosex_0,#rdosex_1&quot;,&quot;1&quot;,&quot;radio&quot;]]'; for(a=$.parseJSON(data),b=a.length-1;0&lt;=b;b--){ c=a[b]; if (c[2] =='text') { $(c[0]).val(c[1]); } else if (c[2] == 'radio'){ rdata = c[0].split(','); rnum = c[1] - 1; select = rdata[rnum]; $(select).attr('checked', true); } } })();'>Drag me!</a></span>
document.getElementsByTagName('head').item(0).appendChild(a);
document.body.appendChild(a);