fork download
  1. <!DOCTYPE html>
  2. <html dir="ltr" lang="ja">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>サンプル</title>
  6. </head>
  7. <body>
  8. <form name=fm>
  9. <input type=search name=k>
  10. <button type=submit name=ggl>google</button>
  11. <button type=submit name=yho>yahoo</button>
  12. </form>
  13.  
  14. <div style="display:none">
  15. <!--google-->
  16. <form name=subggl method=get target=_blank action="http://w...content-available-to-author-only...o.jp/search">
  17. <input type=text name=q><a href="http://w...content-available-to-author-only...o.jp/" target=_blank>top</a></form>
  18. <!--yahoo!-->
  19. <form name=subyho method=get target=_blank action="http://s...content-available-to-author-only...o.jp/search">
  20. <input type=text name=p><a href="http://w...content-available-to-author-only...o.jp/" target=_blank>top</a></form>
  21. </div>
  22.  
  23.  
  24. <script>
  25. addEventListener('load', function(){ var _=0;
  26. function searchOnNewTab(name, v) {
  27. var form = document.forms['sub' + name];
  28. if (v === '') {
  29. form.getElementsByTagName('A')[0].click()
  30. } else {
  31. form.getElementsByTagName('INPUT')[0].value = v;
  32. form.submit();
  33. }
  34. }
  35. document.forms['fm'].addEventListener('click', function(ev){
  36. if (ev.target.type != 'submit') return; // 目的のボタン以外は処理しない
  37. ev.preventDefault();
  38. var form = ev.currentTarget;
  39. var name = ev.target.name;
  40. var valu = form.elements['k'].value;
  41. searchOnNewTab(name, valu);
  42. }, false);
  43. }, false)
  44. </script>
  45. </body>
  46. </html>
Runtime error #stdin #stdout #stderr 0.38s 381888KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
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.