d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Javascript
Add Reply New Topic New Poll
Member
Posts: 10,228
Joined: Oct 27 2008
Gold: 9,834.89
Jul 17 2013 10:39pm
I'm very new and so confused on this...

If I make this small and extremely basic code where if I enter a "password" it logs me some info




var password = prompt ("What's the password?");

if (password = 1111)
{
console.log ("Facebook Password: 5252")
}
else
console.log ("Stop it, you're not Michael")




Is there anywhere I can just "copy and paste" then "save it" as like a desktop icon/application so if i double click on it, it'll just run the code?

**Macbook Air
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Jul 17 2013 10:53pm
it's javascript so you'll need an interpreter, which will most likely be your browser. wrap it in html, then save it as a .html file. then you can double click it and it'll open in your browser and do what you want

eg:
<html>
<head>
<script>
your javascript here
</script>
</head>
</html>

This post was edited by carteblanche on Jul 17 2013 10:56pm
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Jul 18 2013 11:42pm
Quote (Michael515 @ Jul 18 2013 11:02pm)
http://forums.d2jsp.org/topic.php?t=68274018&f=124


So I still am pretty lost... I was wondering if you could help?
I run google chrome, and I know that when I press the button near the top right corner, and go to Tools, then go to JavaScript Console, this thing on the bottom appears up.

And if I put in the code, and press enter it'll work. But from there how do I save it and put it where I want so I can just click on it so it runs?


put it in an html file and you can open it in your browser. i already gave instructions on how to do this. if you're learning javascript before learning what an html file is, go back and learn it.

if you want to be able to execute this on a webpage that is not your own, then you should look into creating an extension / addon or whatever it's called. but you're still a noob, so i wouldnt recommend it. one step at a time.

This post was edited by carteblanche on Jul 18 2013 11:43pm
Member
Posts: 3,963
Joined: May 9 2004
Gold: 2,910.95
Sep 15 2013 01:05am
I think you miss one "="

if (password = 1111)

=>

if (password == 1111)
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll