Mozilla 도움말 검색

고객 지원 사기를 피하세요. 저희는 여러분께 절대로 전화를 걸거나 문자를 보내거나 개인 정보를 공유하도록 요청하지 않습니다. "악용 사례 신고"옵션을 사용하여 의심스러운 활동을 신고해 주세요.

자세히 살펴보기

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

  • 3 답장
  • 2 이 문제를 만남
  • 2 보기
  • 최종 답변자: 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.