Iskanje po podpori

Izogibajte se prevarantski tehnični podpori. Nikoli vam ne bomo naročili, da pokličete telefonsko številko ali nam pošljete osebne podatke. Sumljivo dejavnost prijavite z gumbom »Prijavi zlorabo«.

Več o tem

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

  • 3 odgovori
  • 2 imata to težavo
  • 7 ogledov
  • Zadnji odgovor od 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

Spremenil cor-el

Izbrana rešitev

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
Preberite ta odgovor v kontekstu 👍 0

Vsi odgovori (3)

more options

Izbrana rešitev

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.