4 Replies - 506 Views - Last Post: 07 September 2012 - 03:57 AM

#1 SheWolf  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 02-September 12

Javascript does not work...?

Posted 02 September 2012 - 08:04 PM

I'm using dreamweaver cs6 and chrome to test my code. I'm in an html5 document with a .htm ending. I'm trying to print "hi".
<script>document.write("hi")</script>


this is html5 so it's not like I need to declare it Javascript. I dunno why it doesn't work. Strangely it worked in a PHP file that I was typing HTML in. Also CSS id and class do not work either. Is dreamweaver just FUBAR or am I doing something wrong. This is really annoying...It's like I'm copying word for word from w3schools and it just doesn't work for me.

Is This A Good Question/Topic? 0
  • +

Replies To: Javascript does not work...?

#2 Atli  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3637
  • View blog
  • Posts: 5,765
  • Joined: 08-June 10

Re: Javascript does not work...?

Posted 02 September 2012 - 08:42 PM

Hi.

There's nothing "wrong" with that small snippet you showed us. Perhaps if you showed us the entire page, or better yet, gave us a link to a live demo, we could spot what's wrong.

Also, keep in mind that using document.write() in the body of a page is not the most "flexible" way to write Javascript code. If you're just using it as a test, then that's fine, but if you're doing that in real code then you may want to consider stopping that and using the DOM instead. It gives you far more control over what's going on, and a much better way to manipulate the contents of the page.

View PostSheWolf, on 03 September 2012 - 03:04 AM, said:

Is dreamweaver just FUBAR or am I doing something wrong.

Dreamweaver is usually overkill when it comes to writing simple web apps. It's an IDE for professional developers making large sites, who know what's happening "under the hood" and are using all those fancy UIs to (allegedly) speed up the development. In the hands of new developers, or those unsure of what all those fancy UIs are actually doing, it tends to produce less than desirable results. (If you'd have seen some of the Dreamweaver generated markup I've had to deal with in the past, you'd avoid that thing like the plague... Like I do.)

If you're just writing small web apps, or are just learning this stuff, spare yourself the hundreds of dollars and just go with simple text editors like Notepad++. When it comes to learning, you're better of without all the clutter that IDEs like Dreamweaver add.

View PostSheWolf, on 03 September 2012 - 03:04 AM, said:

It's like I'm copying word for word from w3schools and it just doesn't work for me.

I'd be careful about doing that. Their examples are sometimes... less than ideal.
Was This Post Helpful? 2
  • +
  • -

#3 SheWolf  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 02-September 12

Re: Javascript does not work...?

Posted 03 September 2012 - 01:18 PM

To be honest...I'm just not too sure what I'm doing. The same thing happens in notepad++.
Was This Post Helpful? 0
  • +
  • -

#4 Atli  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3637
  • View blog
  • Posts: 5,765
  • Joined: 08-June 10

Re: Javascript does not work...?

Posted 03 September 2012 - 02:44 PM

Show us the code you are trying. Just post it here it here and we'll take a look at it.
Was This Post Helpful? 0
  • +
  • -

#5 cisprakash  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 03-September 12

Re: Javascript does not work...?

Posted 07 September 2012 - 03:57 AM

Where you put this Javascript code i mean to say in HTML Body, Head or else where you can shift this code into these sections(Body, Head) i think this problem should be sort out.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1