Click to See Complete Forum and Search --> : cut and paste failure! Why oh Why?!


theuberpuppy
09-16-2003, 05:34 PM
Ok, so a code works PERFECTLY when written into the header of the page and a function called from the body.

so, when i cut and paste the script from the header out into a .js file --- WHY does it no longer work.

I have not changed the body script at all, it merely calls a function:<Script type="text/javascript"> <!--
myFunction();
// -->
</script>

and i've left the header as <script type="text/javascript" src="myFile.js"></script>

so what on earth happened?

:confused:

:confused:

:confused:

soccer362001
09-16-2003, 06:14 PM
when you save it as a js file you do not need
<Script type="text/javascript"></script>
you just need
<!--
myFunction();
// -->

theuberpuppy
09-16-2003, 07:02 PM
i tried - but i think maybe you misunderstood...

the myFunction() is not called inside the .js file scripts - that's just where its defined/initialised... it's called later on in the body of the HTML document...

<html>
<header>
<title>Title, look! Yay!</title>
<script language="JavaScript" src="fileContainingAFunction.js"></script>
</header>


<Body>
<script language="JavaScript">
<!--

myFunction();

-->
</script>
</body>

I took out the body part <script> tags and it still didn't work.

If i haven't worked it out tonight, i'll post the url tomorrow (it's notuploaded at the mo) and then you can all tell me how i've done something really simpleand stupid :rolleyes: :(

theuberpuppy
09-16-2003, 07:25 PM
No! Right. sod it - i've had enough...this is too exasperating! It should work - i cannot see any reason why a perfectly good working code should suddenly not be working perfectly when cut and pasted as is into a .js file!!!!!!!! AAAAARRRGGGHHH the nonsensicalness of it all. So, anyway, here's the url - it's not got any pretty pictures or anything cos the site is being totally revised and the new version isn't ready for uplaod yet. This is just a hidden page of code.
The Funky not-working Page! Everybody say "Hello". (http://www.eusa.ed.ac.uk/societies/p+p/campisstemp.htm)


the problem is the code that writes the 'page last modified' bit at the very bottom of the visible. The script is the last one in the header (which will hopefully be getting cleaned up a bit shortly) and the html bit is at the very bottom of the whole thing. Hope that in amongst the mess you can find what the problem is - although most of the page's code has absolutely no bearing on this whatsoever :D

Man, i HATE it when you spend ages on a code and then the thing just gets stubborn on you - and it's AWLAYS a missed out " somewhere - it's just sod's law.

Right, sorry about the moan guys - but any help would be appreciated massively

Cheers
And no, the trousers don';t help with the programming of anything! unfportunately...otherwise they'd be even cooler :D

Fang
09-17-2003, 04:21 AM
theuberpuppy wrote
AAAAARRRGGGHHH
Fang writes AAAAARRRGGGHHH
You problems are caused by invalid code! Validate (http://validator.w3.org/) your code.
Quote ALL attributes.

Also advisable:
Not <SCRIPT language=JavaScript> but <script type="text/javascript">
Put all Javascript in one block.
Put all style in a seperate style sheet document.

theuberpuppy
09-18-2003, 12:27 PM
yeah, its all a bit ongoing - i started writing the page without a clue about anythign to do with anythign webdesign related - as and whe ni find out things i try and update them - some i've left for the time being because they're to do with universal accessibility and i have to get the page up and running for at least ie by next week fully. so, yeah, i agree but haven;t got the time yet to set it up.

anyway, when you say my code isn't valid --- are you referring to the script for the datelastmodified bit or the general code of the webpage? because if it's the webpage - which bits seem to be incorrect - the validation service just screams at me for a million different reasons, so finding the key one is a wee bit tricky given my time frame....

errm, yeah - what's my question... oh yeah... what exactly do you think, at a glance is most in need of fixing to get it to work in a .js?

cheers
Al

wow - i dig web development but bu**er me if there isn't a lot to learn! :D

Fang
09-18-2003, 12:46 PM
Do the suggestions from my previous reply and you will be heading in the right direction.

theuberpuppy
09-18-2003, 08:15 PM
cheers dude

just begining to sort myself out on css (which i assume is what you mean by style sheets) - i'm using some dreamweaver made ones currently, but am gonna change all that - it's a acutally a bit annoying what dreamweaver does - because even if i define something to be a certain style from my style sheet - it still goes and sticks loads of totally redundant <font> tags round it -...and trawling trhough it to get that all out is a flipping nightmare! v. annoying... i hope the new version of dw doesn't do that.

Al

p.s. my trousers now have a hole =0(

pyro
09-18-2003, 10:28 PM
Originally posted by theuberpuppy
i hope the new version of dw doesn't do that.Looks like your prayers have been answered: http://forums.webdeveloper.com/showthread.php?s=&threadid=17783#post93390