Forum Moderators: open

Message Too Old, No Replies

Add to Favourites Problem

         

woldie

3:01 pm on Nov 18, 2004 (gmt 0)

10+ Year Member



Hi,

I've got this 'add to favourites' JavaScript problem. The code below looks like a nightmare initially, but the error I get is ')' is expected, and I've tried to solve this but my JavaScript skills is not best.

Can anyone shed some light on this?

function bookIt(argVal)
{
var bookData = new Array();
bookData = argVal.split("¦");
if (document.all)
{
window.external.AddFavorite(bookData[0], bookData[1]);
}
else
{
alert("Netscape users will need to bookmark this site manually using the keyboard shortcut <Ctrl-D>.");
}
}

This is where code falls down.

<a href="#" onclick="bookIt('javascript:d=document;t=getSelection();void(mark=window.open('http://www.domain.com/save.php?a='+escape(d.title)+'&b='+escape(d.location.href)+'&c='+escape(t)+'&d='+escape(d.lastModified)+'&e='+escape(d.referrer)+'&f='+escape(d.domain),'mark','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=y es'));mark.focus();'); return false;">add this site to your favourites</a>

Many Thanks :o)

adni18

5:12 pm on Nov 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This should work:

<a href="#" onclick="bookIt('javascript:d=document;t=getSelection();void(mark=window.open(\'http://www.domain.com/save.php?a='+escape(d.title)+'&b='+escape(d.location.href)+'&c='+escape(t)+'&d='+escape(d.lastModified)+'&e='+escape(d.referrer)+'&f='+escape(d.domain),\'mark\',\'scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes\'));mark.focus();'); return false;">add this site to your favourites</a>

woldie

5:26 pm on Nov 18, 2004 (gmt 0)

10+ Year Member



Thanks adni18,

Nearly there!

I get this error:

Line: 25
Char: 246
Error: Invalid Character

Many Thanks

adni18

6:40 pm on Nov 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



try replacing focus(); with focus()

woldie

9:03 am on Nov 19, 2004 (gmt 0)

10+ Year Member



Thanks again,

Still got the same problem, I'm afriad.

Here's the code again

its says char 254.

<a href="#" onclick="bookIt('javascript:d=document;t=getSelection();void(mark=window.open(\'http://www.domain.com/save.php?a='+escape(d.title)+'&b='+escape(d.location.href)+'&c='+escape(t)+'&d='+escape(d.lastModified)+'&e='+escape(d.referrer)+'&f='+escape(d.domain),\'mark\',\'scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes\'));mark.focus()'); return false;">add this site to your favourites</a>

Any ideas?

Thanks

adni18

1:10 pm on Nov 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



try d=document;t=document.getSelection();