Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Mar 2009
    Posts
    45
    Thanks
    3
    Thanked 0 Times in 0 Posts

    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

  • #2
    Regular Coder
    Join Date
    Mar 2009
    Location
    Portland Oregon
    Posts
    690
    Thanks
    44
    Thanked 63 Times in 62 Posts
    sounds like it. All yoiu need to do is include script tags with the src

  • #3
    New Coder
    Join Date
    Mar 2009
    Posts
    45
    Thanks
    3
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

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