CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Threaded View

  1. #1
    Join Date
    Nov 2008
    Posts
    1

    using setAttribute to create unique attributes.

    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:
    Code:
    <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:

    Code:
    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.
    Last edited by PeejAvery; November 6th, 2008 at 11:28 AM. Reason: Added code tags.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured