...

View Full Version : BBcode Error - Works, but FF Console Calls an Error ?



Crowds
11-02-2006, 05:53 PM
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



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+" (+string+)";
area.focus ( ) ;
}
else
{
var area = document.getElementById ( id ) ;
area.value += " "+string+" (+string+)"
area.focus ( ) ;
}
}
else
{
document.getElementById ( id ) .focus ( ) ;
}
}



And I am calling it via



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

Any ideas ?

Crowds

_Aerospace_Eng_
11-02-2006, 06:33 PM
Hmm change this

<a href="javascript:" onClick="addurl('txtA')">
<strong><img src="graphics/url.gif" alt="url" width="30" height="20" border="0"/></strong></a>
to this

<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.

Crowds
11-02-2006, 07:18 PM
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.


www.siterunningscript.com/javascriptneedstobenabled.html


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

Crowds

Crowds
11-02-2006, 07:21 PM
Yep you can ! that has sorted it


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

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


<img src="graphics/url.gif" alt="url" width="30" height="20" border="0" title="Add URL" onClick="addurl('txtA')" style="cursor:pointer;cursor:hand"/>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum