View Full Version : js function for Safari - OSX

02-17-2005, 09:43 AM

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;
var sel = document.selection.createRange();
sel.text = '<span class=' + f + '>' + str + '</span>';

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


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

02-17-2005, 01:17 PM
I don't have an answer, but maybe this link will help: