...

View Full Version : js function for Safari - OSX



carlsberg
02-17-2005, 09:43 AM
Hi

I've been developing an admin for a site with a function to select some text for formatting - for a client who was using PCs - so the IE-specific function was not a problem.

I had explained to them that it would not be usable on FireFox, Netscape etc and that didn't seem to worry them - but they forgot to tell me that they'd just ordered a load of Mac Minis !!

So .... now the function doesn't work and i need to include an alternative function for users of Safari on OSX.

the function that works in IE 6 is this :

function format(f) {
var str = document.selection.createRange().text;
document.form1.texte.focus();
var sel = document.selection.createRange();
sel.text = '<span class=' + f + '>' + str + '</span>';
return;
}

I read somewhere that it's the "document.selection.createRange().text" part that doesn't work on Mac and that I need to use

window.getSelection()

instead - is it just as simple as that ??

can you help me please - or point me to a site where they discuss this as i haven't found one

thanks :)

requestcode
02-17-2005, 01:17 PM
I don't have an answer, but maybe this link will help:
http://developer.apple.com/internet/safari/



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum