Go Back   HTMLCenter Web Development Forums > Web Design and Development > Programming and Scripting

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 03-19-2002, 07:46 AM
Registered User
 
Join Date: Mar 2002
Posts: 2
Question Umm. . . not sure what I should call this thread

I was wondering if it is even possible to have replacement codes. ..kinda like the codes here, such as the smilie replacements. I know it can be done using php and stuff, but I am limited to what I can use. . pretty much client side stuff. .hence the reason for posting in here.

So is it possible to setup quick codes that would allow an image to replace them? So this happens --->

Either using Javascript, CSS or DHTML if possible in any of them, would be more than welcomed.

Thanks in advance.
Reply With Quote

  #2 (permalink)  
Old 03-19-2002, 09:37 AM
tthurgo's Avatar
Moderator
 
Join Date: Jan 2002
Location: Lebanon, PA
Posts: 357
Never heard of anything like that.

Do you mean parsing code on the client side?

Tom
Reply With Quote
  #3 (permalink)  
Old 03-19-2002, 09:48 AM
Registered User
 
Join Date: Jan 2002
Posts: 12
maybe this helps:

Code:
<SCRIPT LANGUAGE="JavaScript">

var yourtext = "blabla :smile1: blabla";

var parsedtext = yourtext.replace (/:smile1:/, "<img src=smile1.gif>");

document.write (parsedtext);

</SCRIPT>
__________________
I've been trying to change the world for years, \
but they just won't give me the source code..

watch tv online - TV Stations/Channels Broadcasting from around the World
Reply With Quote
  #4 (permalink)  
Old 03-19-2002, 01:01 PM
Registered User
 
Join Date: Mar 2002
Posts: 2
Ok. .so now how do I apply it so it will change all occurences of :smile: in a given html document?
Reply With Quote
  #5 (permalink)  
Old 03-19-2002, 08:02 PM
Registered User
 
Join Date: Jan 2002
Location: Pittsburgh, PA, USA
Posts: 48
Send a message via ICQ to Nate Send a message via AIM to Nate Send a message via Yahoo to Nate
Emon,

That is the essence of server-side programming. Client-side programming doesn't run until the HTML document is already downloaded to the browser, so I would conclude that there isn't a way to replace a given text in a whole HTML doc. If there is some loophole in javascript that lets you do it, it would probably be 3 pages worth of code and it would take 30-60 seconds for the browser to process it, which would turn users away pretty quick.

Sorry man,
Nate
Reply With Quote
  #6 (permalink)  
Old 03-20-2002, 04:07 AM
tthurgo's Avatar
Moderator
 
Join Date: Jan 2002
Location: Lebanon, PA
Posts: 357
Quote:
Originally posted by Emon
Ok. .so now how do I apply it so it will change all occurences of :smile: in a given html document?
As favo stated, you would have to read the entire HTML document into the variable yourtext. However, I am not sure how that could be achieved through JavaScript.

As Nate put it, you might want to look into server-side programming.

Tom
Reply With Quote
  #7 (permalink)  
Old 03-20-2002, 04:18 AM
Till's Avatar
Administrator
 
Join Date: Jan 2002
Location: Berlin, Germany
Posts: 1,453
Re: Umm. . . not sure what I should call this thread

Quote:
Originally posted by Emon
I was wondering if it is even possible to have replacement codes. ..kinda like the codes here, such as the smilie replacements. I know it can be done using php and stuff, but I am limited to what I can use. . pretty much client side stuff. .hence the reason for posting in here.

So is it possible to setup quick codes that would allow an image to replace them? So this happens --->

Either using Javascript, CSS or DHTML if possible in any of them, would be more than welcomed.

Thanks in advance.
Hi Emon!

Not exactly made for smilies, but for parsing XML through JavaScript is the following tutorial. I went over it and it's quite a tough read, too much hassle for a little parsing if you ask me. But whatever floats your boat.

Check it out: http://www.webreference.com/js/column103/

Maybe you can adapt some things and go from there.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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
Forum Jump


All times are GMT -5. The time now is 01:59 AM.

 
KickApps
Clicky Web Analytics


Subscribe to our feed | add to myYahoo!

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
© 1997-2007 HTMLCenter