Go Back   CodingForums.com > :: Client side development > JavaScript programming > DOM and JSON scripting

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-25-2009, 02:35 AM   PM User | #1
csam0003
New Coder

 
Join Date: Mar 2009
Posts: 45
Thanks: 3
Thanked 0 Times in 0 Posts
csam0003 is an unknown quantity at this point
Javascript function

hi all,

I have a javascript function that inputs span tags around some text in any web page I access. In between these tags, I put onmouseover = Somefunction().
This "Somefunction()" is stored in the same js file which does the insertion.

However I noticed that nothing is happening as Somefunction() is not defined.
Do i have to insert the Somefunction() into the webpage aswell or is there a way I can direct the call to the function in the javascript file?

Thanks alot

Regards
Chris
csam0003 is offline   Reply With Quote
Old 03-25-2009, 02:58 AM   PM User | #2
TinyScript
Regular Coder

 
Join Date: Mar 2009
Location: Portland Oregon
Posts: 690
Thanks: 44
Thanked 63 Times in 62 Posts
TinyScript is on a distinguished road
sounds like it. All yoiu need to do is include script tags with the src
TinyScript is offline   Reply With Quote
Old 03-25-2009, 11:05 AM   PM User | #3
csam0003
New Coder

 
Join Date: Mar 2009
Posts: 45
Thanks: 3
Thanked 0 Times in 0 Posts
csam0003 is an unknown quantity at this point
Thank you TinyScript for your reply.
I really appreciate it.

Can u explain a bit better where I have to put the script and src.

My code is the following:

function something()

wArea = content.document.getElementsByTagName('body')[0];
var openTag = '<span onMouseOver = "testButton()" >';
var closetag = '</span>';
workText = content.getSelection().getRangeAt(0);
var currReplace = new RegExp("("+workText+")");
wArea.innerHTML = wArea.innerHTML.replace(currReplace, openTag+"$1"+closeTag);

As you can see, I am inserting the onmouseover = testButton() as a string in the web page. The function testbutton() is saved in the same js file as function something(). This something() is called when the user clicks on a button I created in Firefox toolbar.

thank you for your time
csam0003 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 07:14 PM.


Advertisement
Log in to turn off these ads.