搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

Learn More

linux I keep getting a error message when running java from scratchpad.

  • 3 个回答
  • 2 人有此问题
  • 7 次查看
  • 最后回复者为 cor-el

more options
I am trying to run a simple java script from Scratchpad.

<html>
<body>

<h1>My First Web Page</h1>

<script>
document.write("<p>My First JavaScript</p>");
</script>

</body>
</html>
######

<html>
<body>

<script>
function myFunction()
{
var x="",i;
for (i=0;i<5;i++)
  {
  x=x + "The number is " + i + "<br>";
  }
document.getElementById("demo").innerHTML=x;
}
</script>

</body>
</html>

the traceback error refers to the var variable;
var x="",i;

I highlight <script> to <script>
and get this error message

/*
Exception: syntax error
Scratchpad:4
*/

this refers to this line var x="",i;

I am trying to run a simple loop that will show the numbers in the loop but the loop crashes.

I need to know how to fix the problem.

jol

<pre><nowiki>I am trying to run a simple java script from Scratchpad. <html> <body> <h1>My First Web Page</h1> <script> document.write("<p>My First JavaScript</p>"); </script> </body> </html> ###### <html> <body> <script> function myFunction() { var x="",i; for (i=0;i<5;i++) { x=x + "The number is " + i + "<br>"; } document.getElementById("demo").innerHTML=x; } </script> </body> </html> the traceback error refers to the var variable; var x="",i; I highlight <script> to <script> and get this error message /* Exception: syntax error Scratchpad:4 */</nowiki></pre> this refers to this line var x="",i; I am trying to run a simple loop that will show the numbers in the loop but the loop crashes. I need to know how to fix the problem. jol

由cor-el于修改

被采纳的解决方案

That is not pure JavaScript code, but HTML code.
You can't run such code via the Scratchpad.
In the second example you are missing a container with the id="demo" and you also are calling the function.

data:text/html;charset=utf-8;base64,PGh0bWw+Cjxib2R5PgoKPGgxPk15IEZpcnN0IFdlYiBQYWdlPC9oMT4KCjxzY3JpcHQ+CmRvY3VtZW50LndyaXRlKCI8cD5NeSBGaXJzdCBKYXZhU2NyaXB0PC9wPiIpOwo8L3NjcmlwdD4KCjwvYm9keT4KPC9odG1sPgo=
data:text/html;charset=utf-8;base64,PGh0bWw+Cjxib2R5Pgo8cCBpZD0iZGVtbyI+PC9wPgoKPHNjcmlwdD4KZnVuY3Rpb24gbXlGdW5jdGlvbigpCnsKdmFyIHg9IiIsaTsKZm9yIChpPTA7aTw1O2krKykKICB7CiAgeD14ICsgIlRoZSBudW1iZXIgaXMgIiArIGkgKyAiPGJyPiI7CiAgfQpkb2N1bWVudC5nZXRFbGVtZW50QnlJZCgiZGVtbyIpLmlubmVySFRNTD14Owp9Cm15RnVuY3Rpb24oKTsKPC9zY3JpcHQ+Cgo8L2JvZHk+CjwvaHRtbD4K
定位到答案原位置 👍 0

所有回复 (3)

more options

选择的解决方案

That is not pure JavaScript code, but HTML code.
You can't run such code via the Scratchpad.
In the second example you are missing a container with the id="demo" and you also are calling the function.

data:text/html;charset=utf-8;base64,PGh0bWw+Cjxib2R5PgoKPGgxPk15IEZpcnN0IFdlYiBQYWdlPC9oMT4KCjxzY3JpcHQ+CmRvY3VtZW50LndyaXRlKCI8cD5NeSBGaXJzdCBKYXZhU2NyaXB0PC9wPiIpOwo8L3NjcmlwdD4KCjwvYm9keT4KPC9odG1sPgo=
data:text/html;charset=utf-8;base64,PGh0bWw+Cjxib2R5Pgo8cCBpZD0iZGVtbyI+PC9wPgoKPHNjcmlwdD4KZnVuY3Rpb24gbXlGdW5jdGlvbigpCnsKdmFyIHg9IiIsaTsKZm9yIChpPTA7aTw1O2krKykKICB7CiAgeD14ICsgIlRoZSBudW1iZXIgaXMgIiArIGkgKyAiPGJyPiI7CiAgfQpkb2N1bWVudC5nZXRFbGVtZW50QnlJZCgiZGVtbyIpLmlubmVySFRNTD14Owp9Cm15RnVuY3Rpb24oKTsKPC9zY3JpcHQ+Cgo8L2JvZHk+CjwvaHRtbD4K
more options

Sorry for the previously submitted unprecise question. I was told that the code was java.

I'm a python programmer and know zero about java. However I could solve my problem if there were a way to run a python module from scratchpad. Or, maybe a linux script file

If not , my problem is that I am trying to send to a web page entry field a 10 digit number every time I update the web page. So, I need to create a file that will send this number when it is called from Scratchpad. I can create a new file with a new number prior to updating the web page.

I am planning to use a Firefox macro to call Scratchpad to run the file that will submit the new number.

I can deal with the macro but I haven't been successful in sending the number to the entry field and I believe a simple java file will work.

I would appreciate any suggestions.

jimonlinux

more options

You can use code like this to set the value of an input field.

document.getElementById("<id_of_input_field>").value="<value>"

You can also do this via a JavaScript bookmarklet placed on the Bookmarks Toolbar and click that icon.

javascript:void(document.getElementById("<id_of_input_field>").value="##########");

A good place to ask advice about web development is at the MozillaZine "Web Development/Standards Evangelism" forum.

The helpers at that forum are more knowledgeable about web development issues.
You need to register at the MozillaZine forum site in order to post at that forum.