skribbs
November 6th, 2008, 09:12 AM
Alright please let me know if this is even possible.
I'm trying to load a javascript using javascript but I need some unique attributes.
Heres what I want:
<SCRIPT TYPE="text/javascript" for="CoolPlugin" event="specialEvent(methodName, parameters)" src="coolPlugin.js"> </SCRIPT>
Heres what I'm doing:
//I have a simple javascript file that gets loaded when the body loads, theres an 'init()' function that gets called and heres whats inside it:
init(){
var head = document.getElementsByTagName('head')[0];
var tag = document.createElement('script');
tag.setAttribute('type', 'text/javascript');
tag.setAttribute('src', 'coolPlugin.js');
tag.setAttribute('for', 'CoolPlugin');
tag.setAttribute('event', 'specialEvent(methodName, parameters)');
head.appendChild(tag);
}
What supposed to happen is that the event reacts to a key press (lets say when the user presses '1') and the font changes colors
From what it looks like, the 'for' and 'event' attribute dont seem to get appended.
Please let me know if you have any comments, suggestions, ideas, or any incite on solving this problem.
I'm trying to load a javascript using javascript but I need some unique attributes.
Heres what I want:
<SCRIPT TYPE="text/javascript" for="CoolPlugin" event="specialEvent(methodName, parameters)" src="coolPlugin.js"> </SCRIPT>
Heres what I'm doing:
//I have a simple javascript file that gets loaded when the body loads, theres an 'init()' function that gets called and heres whats inside it:
init(){
var head = document.getElementsByTagName('head')[0];
var tag = document.createElement('script');
tag.setAttribute('type', 'text/javascript');
tag.setAttribute('src', 'coolPlugin.js');
tag.setAttribute('for', 'CoolPlugin');
tag.setAttribute('event', 'specialEvent(methodName, parameters)');
head.appendChild(tag);
}
What supposed to happen is that the event reacts to a key press (lets say when the user presses '1') and the font changes colors
From what it looks like, the 'for' and 'event' attribute dont seem to get appended.
Please let me know if you have any comments, suggestions, ideas, or any incite on solving this problem.