User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 429,992 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,429 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 712 | Replies: 2 | Solved
Reply
Join Date: Jul 2008
Posts: 2
Reputation: emit_flesti is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
emit_flesti emit_flesti is offline Offline
Newbie Poster

JS won't work unless empty script tags present

  #1  
Jul 3rd, 2008
This is the weirdest problem I've seen so far. But upfront this is my first javascript development. I've mostly programmed in Actionscript and PHP.

I have quite a bit of javascript running on my PHP page. I had just gotten everything to work well (looking at you IE7!) and I moved one function to another place because out of the blue I was getting "function is not defined."

From there everything went wrong. Soon the page wouldn't register any functions. I moved it all to an external .js file and that solved nothing.

So I went back to where it all went wrong. One by one as I used the page I would get an undefined function error. So I moved these one by one to a different part of the page. Soon I was able to get all the code working but I had my leftover <script> tags.

<link href="css/main.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="js/jsTrace-uc.js"/>
<script type="text/javascript" src="js/dom-drag.js"/>
<script type="text/javascript">
</script>
<script type="text/javascript">
  function listHide(boxid){
    document.getElementById(boxid).style.visibility = "hidden";
    document.getElementById(boxid).style.display = "none";
  }
...

So I deleted this and lo and behold, the page stopped working completely again. So I put it back in and it worked!

As I said I haven't done any real Javascript before so I don't really know the nuances of the page structure concerning the scripting environment. But this seems like a very very odd issue.

But it's one of those "how the hell did I ever figure that out."

In case someone is bored and wants to figure this out I've attached the code. I wouldn't mind knowing (for future reference) why in the world this is happening.
Attached Files
File Type: txt build.txt (8.2 KB, 0 views)
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2005
Location: New York state
Posts: 468
Reputation: ShawnCplus will become famous soon enough ShawnCplus will become famous soon enough 
Rep Power: 5
Solved Threads: 72
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

Re: JS won't work unless empty script tags present

  #2  
Jul 3rd, 2008
It doesn't work because script tags can never be short-tags i.e., <tagname />, they must be explicitly closed i.e., <tagname></tagname>
GCS d- s+:+ a-->? C++(++++) UL+++ P+>+++ L+++ !E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r z+*
Reply With Quote  
Join Date: Jul 2008
Posts: 2
Reputation: emit_flesti is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
emit_flesti emit_flesti is offline Offline
Newbie Poster

Re: JS won't work unless empty script tags present

  #3  
Jul 3rd, 2008
Thanks! I was just thinking about that this morning. I've been looking at the JS for the problem I just looked it right over.

But those tags have been like that since I put them in and only in the past two days did I get the 'function is not defined' error.

But thanks again. I knew it was something stupidly simple.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 12:38 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC