TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 01-25-2008, 05:45 PM   #1 (permalink)
Nor
The Addict
 
Join Date: Nov 2007
Posts: 282
Thanks: 61
Nor is on a distinguished road
Default Is selectionEnd and selectionStart crossbrowser?

I was wondering because I was looking at a tutorial for applying bulletin board code, and I'm not to sure if this would be supported in all browsers.

Tutorial I was refering to: Apply bbcode with JavaScript | Tb-one.se
__________________
PHP/XHTML Freelancer:
Cleanscript.com v3 - Programming starting at just $5 act now!
Nor is offline  
Reply With Quote
Old 01-25-2008, 06:35 PM   #2 (permalink)
Alan @ CIT
Member of the Month
The Frequenter
Member of the Month Top Contributor 
 
Alan @ CIT's Avatar
 
Join Date: Apr 2005
Location: South UK
Posts: 483
Thanks: 51
Alan @ CIT is on a distinguished road
Default

No idea about the javascript I'm afraid but PHP does provide a BBCode extension which may be worth looking at

PHP: BBCode - Manual

Alan
Send a message via MSN to Alan @ CIT
Alan @ CIT is offline  
Reply With Quote
Old 01-25-2008, 08:19 PM   #3 (permalink)
Nor
The Addict
 
Join Date: Nov 2007
Posts: 282
Thanks: 61
Nor is on a distinguished road
Default

I didn't ask for php, I asked if its cross browsed and php is server side scripting. Some said its cross browsered im unsure I'll find out.
__________________
PHP/XHTML Freelancer:
Cleanscript.com v3 - Programming starting at just $5 act now!
Nor is offline  
Reply With Quote
Old 01-25-2008, 08:22 PM   #4 (permalink)
Alan @ CIT
Member of the Month
The Frequenter
Member of the Month Top Contributor 
 
Alan @ CIT's Avatar
 
Join Date: Apr 2005
Location: South UK
Posts: 483
Thanks: 51
Alan @ CIT is on a distinguished road
Default

I know that, I was just mentioning that since you where building a BBCode system, PHP has an extension which might help - not with the javascript used to put the tags in your editor of course, but perhaps with other bits

Alan
Send a message via MSN to Alan @ CIT
Alan @ CIT is offline  
Reply With Quote
Old 01-25-2008, 09:00 PM   #5 (permalink)
Nor
The Addict
 
Join Date: Nov 2007
Posts: 282
Thanks: 61
Nor is on a distinguished road
Default

Yeah, I've already built a system, thanks though.
__________________
PHP/XHTML Freelancer:
Cleanscript.com v3 - Programming starting at just $5 act now!
Nor is offline  
Reply With Quote
Old 01-25-2008, 09:24 PM   #6 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

In answer to the question posed as the topic title, no. If I remember correctly (it's been a while) Firefox (and other gecko browsers) does things one way (selectionStart/End), IE does things another way, other browsers have their own ways and some just plain don't do it at all.

I could be wrong but I doubt things have changed all very much since I played around with this kind of thing some time ago.
Salathe is offline  
Reply With Quote
Old 01-25-2008, 09:41 PM   #7 (permalink)
Nor
The Addict
 
Join Date: Nov 2007
Posts: 282
Thanks: 61
Nor is on a distinguished road
Default

Your correct, I got this code so far:

Code:
<html>
<head>
<title>Debug mode</title>
<script type='text/javascript'>
function insertTag(tag)
{
	if(document.selection)
	{
	
	}
	else
	{
		var v = window.document.f.post;
		var start = v.value.substr(0,v.selectionStart);
		var end = v.value.substr(v.selectionEnd,v.value.length);
		var middle = v.value.substr(v.selectionStart,v.selectionEnd);
		content = start + "["+tag+"]" + middle + "[/"+tag+"]" + end
		//v.value = content
		alert(start+" ------ "+middle+" ------ "+end);
	}
}
</script>
</head>
<body>
<input onclick='insertTag("b")' type='button' value='b' />
<input onclick='insertTag("i")' type='button' value='i' />
<input onclick='insertTag("u")' type='button' value='u' />
<input onclick='insertTag("s")' type='button' value='s' />
<input onclick='insertTag("sub")' type='button' value='sub' />
<form name='f' action='' method='post'>
<textarea cols=100 rows=10 name='post'></textarea>
</form>

</body>
</html>
Example code: Debug mode

In IE 7 I added the if statement because the start position and end position would grab all text :(, so I added the if statement can someone help me learn how to get it working with IE 7. createRange is confusing.
__________________
PHP/XHTML Freelancer:
Cleanscript.com v3 - Programming starting at just $5 act now!
Nor is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 12:59 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design