<!DOCTYPE html>
<html dir="ltr" lang="ja">
<head>
<meta charset="utf-8">
<title>サンプル</title>
</head>
<body>
<form name=fm>
<input type=search name=k>
<button type=submit name=ggl>google</button>
<button type=submit name=yho>yahoo</button>
</form>
<div style="display:none">
<!--google-->
<form name=subggl method=get target=_blank action="http://w...content-available-to-author-only...o.jp/search">
<input type=text name=q><a href="http://w...content-available-to-author-only...o.jp/" target=_blank>top</a></form>
<!--yahoo!-->
<form name=subyho method=get target=_blank action="http://s...content-available-to-author-only...o.jp/search">
<input type=text name=p><a href="http://w...content-available-to-author-only...o.jp/" target=_blank>top</a></form>
</div>
<script>
addEventListener('load', function(){ var _=0;
function searchOnNewTab(name, v) {
var form = document.forms['sub' + name];
if (v === '') {
form.getElementsByTagName('A')[0].click()
} else {
form.getElementsByTagName('INPUT')[0].value = v;
form.submit();
}
}
document.forms['fm'].addEventListener('click', function(ev){
if (ev.target.type != 'submit') return; // 目的のボタン以外は処理しない
ev.preventDefault();
var form = ev.currentTarget;
var name = ev.target.name;
var valu = form.elements['k'].value;
searchOnNewTab(name, valu);
}, false);
}, false)
</script>
</body>
</html>
PCFET0NUWVBFIGh0bWw+CjxodG1sIGRpcj0ibHRyIiBsYW5nPSJqYSI+CjxoZWFkPgoJPG1ldGEgY2hhcnNldD0idXRmLTgiPgoJPHRpdGxlPuOCteODs+ODl+ODqzwvdGl0bGU+CjwvaGVhZD4KPGJvZHk+Cgk8Zm9ybSBuYW1lPWZtPgoJCQk8aW5wdXQgdHlwZT1zZWFyY2ggbmFtZT1rPgoJCQk8YnV0dG9uIHR5cGU9c3VibWl0IG5hbWU9Z2dsPmdvb2dsZTwvYnV0dG9uPgoJCQk8YnV0dG9uIHR5cGU9c3VibWl0IG5hbWU9eWhvPnlhaG9vPC9idXR0b24+Cgk8L2Zvcm0+Cgo8ZGl2IHN0eWxlPSJkaXNwbGF5Om5vbmUiPgoJPCEtLWdvb2dsZS0tPgoJPGZvcm0gbmFtZT1zdWJnZ2wgbWV0aG9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SddLmFkZEV2ZW50TGlzdGVuZXIoJ2NsaWNrJywgZnVuY3Rpb24oZXYpewogICAgICAgIGlmIChldi50YXJnZXQudHlwZSAhPSAnc3VibWl0JykgcmV0dXJuOyAvLyDnm67nmoTjga7jg5zjgr/jg7Pku6XlpJbjga/lh6bnkIbjgZfjgarjgYQKICAgICAgICBldi5wcmV2ZW50RGVmYXVsdCgpOwogICAgICAgIHZhciBmb3JtID0gZXYuY3VycmVudFRhcmdldDsKICAgICAgICB2YXIgbmFtZSA9IGV2LnRhcmdldC5uYW1lOwogICAgICAgIHZhciB2YWx1ID0gZm9ybS5lbGVtZW50c1snayddLnZhbHVlOwogICAgICAgIHNlYXJjaE9uTmV3VGFiKG5hbWUsIHZhbHUpOwogICAgfSwgZmFsc2UpOwp9LCBmYWxzZSkKPC9zY3JpcHQ+CjwvYm9keT4KPC9odG1sPg==
js: "prog.js", line 25: syntax error
js: addEventListener('load', function(){ var _=0;
js: ........................................^
js: "prog.js", line 43: syntax error
js: }, false)
js: ^
js: "prog.js", line 44: unterminated regular expression literal
js: </script>
js: ........^
js: "prog.js", line 45: unterminated regular expression literal
js: </body>
js: ......^
js: "prog.js", line 46: unterminated regular expression literal
js: </html>
js: ......^
js: "prog.js", line 1: Compilation produced 5 syntax errors.