How do i get my code to run...

Alphabetize

Spoonisi
9 years ago

0

I have written my code (java script) but i have no idea how to get it to run in the HTML as it does not work by using inspect element in the developers tools because when loading the page it over writes this code can someone please help…..
Thank you

18replies
5voices
344views
Yuriko
9 years ago

0

It depends of the browser you are using, but you should find something like Javascript Console, or Console in its Developers Tools section.

Spoonisi
9 years ago | edited 9 years ago

0

At the moment in just inserting the text into chrome using inspect element and then editing the HTML… but whenever i reload the page to run the script my code is removed , i just want to know how to run the script live on the web page as to get the text that changes every time you try and pass the level

Mugi [Mugiwara27]
9 years ago

0

Hey @Spoonisi, @Yuriko just told you how to do it
Chrome / Firefox : ight click –> Inspect element –> Console

Reply has been removed
Spoonisi
9 years ago

0

Im just a little lost with getting it to work maybe its my code

Yuriko
9 years ago

0

@Spoonisi : I think you just misunderstood what you are doing. (And there is nothing wrong in that.)

When your browser first loaded the page, it loaded the HTML code (that may or may not have javascript inside). You are free to edit your HTML code, affecting simultaneously the way the page looks. However when you reload the page, you reload it. That means that your browser downloads, and shows the original HTML code (that may or may not have javascript inside). All your changes has been discarded.

Be careful about the words you use:

[quote=Spoonisi]At the moment in just inserting the text into chrome using inspect element and then editing the HTML… but whenever i reload the page to run the script my code is removed [/quote]
(emphasis are mine)

You are talking about “text”, “HTML”, “script” and “code”. These are not the same thing; for me at least. I would use “text” for something that is not code. “HTML” and “script” (javascript I suppose) are two different languages, and “code” is a general term that could mean both of them in this context.

What you probably wanted to ask was how to run your javascript code. Well, you can’t just paste it into your HTML content and expect it to work; your browser may need a reason to run it (and it might be possible that some security mechanism forbid it too).

A proper way to run it is to use the Console (or Javascript Console). This is a component of the Developers Tools that allows you to execute javascript code on the loaded page. This means that your code can interact with the content of the page. That being so, if you know a way to use javascript to grab the words displayed, sort them, write them in the answer section and submit the form, you can totally complete the level that way. (But eh, remember the five seconds limit? You better be quick, or use copy-paste.)

Spoonisi
9 years ago

0

Hi i apologise for the way i worded that i see its quite confusing.

I am basically inserting to the HTML page and i see how it will not work.

ill try the correct method and see if i pass thank you very much for your input.

One last question tho, if i edit the time limit by inspecting the element and changing “5” to “10000” to give me 10000 seconds , will that allow me to still paste the new text and pass the level or does that just start a timer that doesnt affect the level itself?

? [bolofecal]
9 years ago

0

Try to use the browser’s console to input direct javasctipt. Some browser uses F12 to access it.

Yuriko
9 years ago

0

@Spoonisi : No, that won’t work, because the real countdown is handled by the server. That means that the server sends the page to you and waits five seconds for you answer. The countdown you see is just an indication.

However, if the countdown was implemented in such a way that it was handled by javascript code, you might have been able to complete the level by editing the code (HTML and/or javascript).

Spoonisi
9 years ago

0

Thank you so much you really have been a great help

? [bolofecal]
9 years ago

0

@Spoonisi you are welcome.

@Yuriko of course, if the countdown is in the client side the captca levels will be easy. lol

Spoonisi
9 years ago

0

Im having problems displaying the text in the answer text area , does one need to copy paste or can you code it to display

? [bolofecal]
9 years ago

0

You can code to display it.

:)

Spoonisi
9 years ago

0

could you maybe tell me why this code doesn’t work in writing the new text to the answer text field

document.getElementsByName(“answer”).innerHTML = text;

Yuriko
9 years ago | edited 9 years ago

0

http://www.w3schools.com/jsref/met_doc_getelementsbyname.asp
http://www.w3schools.com/jsref/dom_obj_textarea.asp
EDIT: Or you can read the following post.
EDIT: Or you can read the following posts.

? [bolofecal]
9 years ago

0

Can be exists many elements with same name, like an array, you must specify. You must set value to textarea not innerHTML.

dloser
9 years ago

0

getElementsByName

Also, textarea doesn’t quite work that way.

You might want to invest in your debugging skills. It’s quite easy to figure out what’s wrong by decomposing the statement. (And perhaps googling a bit.)

2 replies have been removed
Spoonisi
9 years ago | edited 9 years ago

0

I have gotten it correct, thank you all for your help i really appreciate it…

? [bolofecal]
9 years ago

0

You’re welcome and congrats about coding 1. Now you can try coding 2.

:)

You must be logged in to reply to this discussion. Login
1 of 19

This site only uses cookies that are essential for the functionality of this website. Cookies are not used for tracking or marketing purposes.

By using our site, you acknowledge that you have read and understand our Privacy Policy, and Terms of Service.

Dismiss