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 4 of 4
  1. #1
    Regular Coder
    Join Date
    May 2005
    Posts
    235
    Thanks
    0
    Thanked 0 Times in 0 Posts

    BBcode Error - Works, but FF Console Calls an Error ?

    I have some bbcode that wraps url tags around a hyperlink. the link is set via a prompt box in a post comment form. It functions fine and wraps things around the link nicely. But it calls an error in the console in Firefox.

    Error: uncaught exception: Permission denied to call method Location.toString


    The Code is

    Code:
    function addurl ( id )
    {
    string = prompt ( "Insert here the url","http://" ) ;
    if ( string!=null && string!="" )
    {
    string2 = prompt ( "Insert the name of the link.", "" ) ;
    if ( string2!=null && string2!="" )
    {
    var area = document.getElementById ( id ) ;
    area.value += " "+string2+" ";
    area.focus ( ) ;
    }
    else
    {
    var area = document.getElementById ( id ) ;
    area.value += " "+string+" "
    area.focus ( ) ;
    }
    }
    else
    {
    document.getElementById ( id ) .focus ( ) ;
    }
    }
    And I am calling it via

    Code:
    <a href="javascript:" onClick="addurl('txtA')">
    <strong><img src="graphics/url.gif" alt="url" width="30" height="20" border="0"/></strong></a>
    Don't want to be scaring FF users off

    Any ideas ?

    Crowds
    PHP magpie | And President Of The Marmalade Atkins Fan Club | Crowds Design

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Hmm change this
    Code:
    <a href="javascript:" onClick="addurl('txtA')">
    <strong><img src="graphics/url.gif" alt="url" width="30" height="20" border="0"/></strong></a>
    to this
    Code:
    <a href="javascriptneedstobenabled.html" onClick="addurl('txtA');return false">
    <img src="graphics/url.gif" alt="url" width="30" height="20" border="0"/></a>
    Using just javascript: will bring up the javascript console which is where the permission denied was coming from. Making the link not go anywhere seems like it should fix that.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    Regular Coder
    Join Date
    May 2005
    Posts
    235
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Aerospace_Eng,

    Just tried it and it does make it go somewhere !
    It appends whatever is added to the prompt box to the end of the current Url. And automaticaly tries to go to this new address... which leads me to an error page because the page does not exist.


    Hhmmm Can you add onClick events to images themselves ? that would negate the need for a link ?

    Crowds
    PHP magpie | And President Of The Marmalade Atkins Fan Club | Crowds Design

  • #4
    Regular Coder
    Join Date
    May 2005
    Posts
    235
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yep you can ! that has sorted it

    Code:
    <img src="graphics/url.gif" alt="url" width="30" height="20" border="0" title="Add URL" onClick="addurl('txtA')"/>
    Only trouble is it will not appear clickable... Hmmm how do I change cursor on a mouse over

    Edit:
    This I sorted by applying a style to it..

    Code:
    <img src="graphics/url.gif" alt="url" width="30" height="20" border="0" title="Add URL" onClick="addurl('txtA')" style="cursor:pointer;cursor:hand"/>
    Last edited by Crowds; 11-02-2006 at 09:55 PM. Reason: Update with solution
    PHP magpie | And President Of The Marmalade Atkins Fan Club | Crowds Design


  •  

    Posting Permissions

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