Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Simple Script doesnt work...
Old 08-15-2006, 07:52 PM Simple Script doesnt work...
Extreme Talker

Posts: 176
Trades: 0
hello there i am having trouble getting this script to work:

index.html
Code:
<html>
<head>
<script type="text/javascript">
function includescript(sourcefile){
var scriptNode = document.createElement('script');
scriptNode.type = 'text/javascript';
scriptNode.src = sourcefile; 
document.getElementsByTagName("head")[0].appendChild(scriptNode);
}
onload=function(){includescript('main.js')}
</script>
</head>
<body>
	<div id="login">loading...</div>
</body>
</html>
main.js
Code:
includescript('functions.js');

if (document.getElementById('login')){
document.getElementById('login').innerHTML = '<script type="text\/javascript" src="loginform.js"><\/script>';
}else{
alert('You must create a login div!');		
}
loginform.js
Code:
document.write('it works!');
the problem is that main.js does not include functions.js OR change the login div to display it works!....
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Last edited by wmtalk.tk; 08-15-2006 at 07:54 PM..
wmtalk.tk is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-15-2006, 08:17 PM Re: Simple Script doesnt work...
funkdaddu's Avatar
Web Design Snob

Posts: 635
Trades: 0
Why not just link to the .js files normally?:
Code:
<script type="text/javascript" src="main.js"></script>
<script type="text/javascript" src="functions.js"></script>
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Old 08-15-2006, 08:28 PM Re: Simple Script doesnt work...
Extreme Talker

Posts: 176
Trades: 0
Quote:
Originally Posted by funkdaddu View Post
Why not just link to the .js files normally?:
Code:
<script type="text/javascript" src="main.js"></script>
<script type="text/javascript" src="functions.js"></script>
i need them to load after the divs loaded so i can use getElementById to write the data.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
wmtalk.tk is offline
Reply With Quote
View Public Profile
 
Old 08-15-2006, 10:15 PM Re: Simple Script doesnt work...
funkdaddu's Avatar
Web Design Snob

Posts: 635
Trades: 0
Can you put your code into a function and call it when the window loads?
Code:
window.onload = function() {
     document.getElementById('login').innerHTML = "It works!";
}
This code does teh same thing your code above does... is that all you want to do is write to a div? Just to do that, your script is over-complicated.

Last edited by funkdaddu; 08-15-2006 at 10:41 PM..
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Old 08-15-2006, 10:44 PM Re: Simple Script doesnt work...
Extreme Talker

Posts: 176
Trades: 0
no, the script is going to be very large when its done so i wanted to split it up into multiple files, and that way it could be customized easier also..

nvm i got it..
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Last edited by wmtalk.tk; 08-15-2006 at 11:58 PM..
wmtalk.tk is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Simple Script doesnt work...
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15419 seconds with 12 queries