473,713 Members | 2,763 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

replace instances of text on page with image or other text?

Hello,

I need to look through the text on a page and replace certain words with an
image or other word

something like:

read document
find all instances of the word "blah"
change all instances of the word "blah" to <img src="MyPicture. jpg" >
(jeez, I don't get why computers cant just read english!<G>)
and, no, I cant just change the page with 'find/replace' in notepad.

--
thanks,
juglesh B>{)}
Jul 23 '05 #1
16 12388
"juglesh" <ju*****@nospam RadioKDUG.com> wrote in message
news:Sj_xd.3022 69$R05.120039@a ttbi_s53...
Hello,

I need to look through the text on a page and replace certain words with an image or other word

something like:

read document
find all instances of the word "blah"
change all instances of the word "blah" to <img src="MyPicture. jpg" >
(jeez, I don't get why computers cant just read english!<G>)
and, no, I cant just change the page with 'find/replace' in notepad.

--
thanks,
juglesh B>{)}


It is not clear -- who's page?

For any given URL do you want to change "certain words" and display it or
what?
Jul 23 '05 #2

"McKirahan" <Ne**@McKirahan .com> wrote in message
news:7C_xd.2680 87$HA.48168@att bi_s01...
"juglesh" <ju*****@nospam RadioKDUG.com> wrote in message
news:Sj_xd.3022 69$R05.120039@a ttbi_s53...
Hello,

I need to look through the text on a page and replace certain words with an
image or other word

something like:

read document
find all instances of the word "blah"
change all instances of the word "blah" to <img src="MyPicture. jpg" >
(jeez, I don't get why computers cant just read english!<G>)
and, no, I cant just change the page with 'find/replace' in notepad.

--
thanks,
juglesh B>{)}


It is not clear -- who's page?


well, my .php is being included in their page(which they made for me) . my
..php page contains the head and the body tag, so i can put in a javascript,
and call it from body onload. basically, when it gets to your browser, you
see my head content, and most of the body is theirs.

For any given URL do you want to change "certain words" and display it or
what?


so, not any given url, just on the pages where my head content is used.

their page is:
<?php include 'http://www.mydomain.co m/head.php'; ?>
<p> Welcome. Content is here. blah and blah</p>
</body>

my head.php is
<head>
<my javascript>
</head>
<body>

i want my js to change all instances of 'blah' to <img src="MyPicture. jpg" >

which would change the output to:
Welcome. Content is here. <the image> and <the image>


Jul 23 '05 #3
"juglesh" <ju*****@nospam RadioKDUG.com> wrote in message
news:lZ_xd.6894 46$mD.299515@at tbi_s02...

"McKirahan" <Ne**@McKirahan .com> wrote in message
news:7C_xd.2680 87$HA.48168@att bi_s01...
"juglesh" <ju*****@nospam RadioKDUG.com> wrote in message
news:Sj_xd.3022 69$R05.120039@a ttbi_s53...
Hello,

I need to look through the text on a page and replace certain words
with
an
image or other word

something like:

read document
find all instances of the word "blah"
change all instances of the word "blah" to <img src="MyPicture. jpg"

(jeez, I don't get why computers cant just read english!<G>)
and, no, I cant just change the page with 'find/replace' in notepad.

--
thanks,
juglesh B>{)}
It is not clear -- who's page?


well, my .php is being included in their page(which they made for me) .

my .php page contains the head and the body tag, so i can put in a javascript, and call it from body onload. basically, when it gets to your browser, you see my head content, and most of the body is theirs.

For any given URL do you want to change "certain words" and display it

or what?


so, not any given url, just on the pages where my head content is used.

their page is:
<?php include 'http://www.mydomain.co m/head.php'; ?>
<p> Welcome. Content is here. blah and blah</p>
</body>

my head.php is
<head>
<my javascript>
</head>
<body>

i want my js to change all instances of 'blah' to <img src="MyPicture. jpg"
which would change the output to:
Welcome. Content is here. <the image> and <the image>


Will this work? Watch for word-wrap.

<head>
<script type="text/javascript">
function MyHead() {
var find = "blah and blah";
var repl = "<img src='MyPicture. jpg'>";
var page = document.body.i nnerHTML;
while (page.indexOf(f ind) >= 0) {
var i = page.indexOf(fi nd);
var j = find.length;
page = page.substr(0,i ) + repl + page.substr(i+j );
document.body.i nnerHTML = page;
}
}
</script>
</head>
<body onload="MyHead( )">
Jul 23 '05 #4
make that:

var find = "blah";
Jul 23 '05 #5

"McKirahan" <Ne**@McKirahan .com> wrote in message
news:Wd0yd.5407 96$wV.495762@at tbi_s54...
"juglesh" <ju*****@nospam RadioKDUG.com> wrote in message
news:lZ_xd.6894 46$mD.299515@at tbi_s02...

"McKirahan" <Ne**@McKirahan .com> wrote in message
news:7C_xd.2680 87$HA.48168@att bi_s01...
> "juglesh" <ju*****@nospam RadioKDUG.com> wrote in message
> news:Sj_xd.3022 69$R05.120039@a ttbi_s53...
>> Hello,
>>
>> I need to look through the text on a page and replace certain words with > an
>> image or other word
>>
>> something like:
>>
>> read document
>> find all instances of the word "blah"
>> change all instances of the word "blah" to <img
>> src="MyPicture. jpg"

>>
>>
>> (jeez, I don't get why computers cant just read english!<G>)
>> and, no, I cant just change the page with 'find/replace' in notepad.
>>
>> --
>> thanks,
>> juglesh B>{)}
>>
>>
>
> It is not clear -- who's page?


well, my .php is being included in their page(which they made for me) .

my
.php page contains the head and the body tag, so i can put in a

javascript,
and call it from body onload. basically, when it gets to your browser,

you
see my head content, and most of the body is theirs.
>
> For any given URL do you want to change "certain words" and display it or > what?


so, not any given url, just on the pages where my head content is used.

their page is:
<?php include 'http://www.mydomain.co m/head.php'; ?>
<p> Welcome. Content is here. blah and blah</p>
</body>

my head.php is
<head>
<my javascript>
</head>
<body>

i want my js to change all instances of 'blah' to <img
src="MyPicture. jpg"
which would change the output to:
Welcome. Content is here. <the image> and <the image>


Will this work? Watch for word-wrap.

<head>
<script type="text/javascript">
function MyHead() {
var find = "blah and blah";
var repl = "<img src='MyPicture. jpg'>";
var page = document.body.i nnerHTML;
while (page.indexOf(f ind) >= 0) {
var i = page.indexOf(fi nd);
var j = find.length;
page = page.substr(0,i ) + repl + page.substr(i+j );
document.body.i nnerHTML = page;
}
}
</script>
</head>
<body onload="MyHead( )">


almost works! if i change repl to a different word, it will work (it will
display another word), but if i use that img tag, nothing changes.


Jul 23 '05 #6

"juglesh" <ju*****@nospam RadioKDUG.com> wrote in message
news:Lf1yd.6127 32$D%.496186@at tbi_s51...

"McKirahan" <Ne**@McKirahan .com> wrote in message
news:Wd0yd.5407 96$wV.495762@at tbi_s54...
"juglesh" <ju*****@nospam RadioKDUG.com> wrote in message
news:lZ_xd.6894 46$mD.299515@at tbi_s02...

"McKirahan" <Ne**@McKirahan .com> wrote in message
news:7C_xd.2680 87$HA.48168@att bi_s01...
> "juglesh" <ju*****@nospam RadioKDUG.com> wrote in message
> news:Sj_xd.3022 69$R05.120039@a ttbi_s53...
>> Hello,
>>
>> I need to look through the text on a page and replace certain words

with
> an
>> image or other word
>>
>> something like:
>>
>> read document
>> find all instances of the word "blah"
>> change all instances of the word "blah" to <img
>> src="MyPicture. jpg"

>>
>>
>> (jeez, I don't get why computers cant just read english!<G>)
>> and, no, I cant just change the page with 'find/replace' in notepad.
>>
>> --
>> thanks,
>> juglesh B>{)}
>>
>>
>
> It is not clear -- who's page?

well, my .php is being included in their page(which they made for me) .

my
.php page contains the head and the body tag, so i can put in a

javascript,
and call it from body onload. basically, when it gets to your browser,

you
see my head content, and most of the body is theirs.

>
> For any given URL do you want to change "certain words" and display it

or
> what?

so, not any given url, just on the pages where my head content is used.

their page is:
<?php include 'http://www.mydomain.co m/head.php'; ?>
<p> Welcome. Content is here. blah and blah</p>
</body>

my head.php is
<head>
<my javascript>
</head>
<body>

i want my js to change all instances of 'blah' to <img
src="MyPicture. jpg"
which would change the output to:
Welcome. Content is here. <the image> and <the image>


Will this work? Watch for word-wrap.

<head>
<script type="text/javascript">
function MyHead() {
var find = "blah and blah";
var repl = "<img src='MyPicture. jpg'>";
var page = document.body.i nnerHTML;
while (page.indexOf(f ind) >= 0) {
var i = page.indexOf(fi nd);
var j = find.length;
page = page.substr(0,i ) + repl + page.substr(i+j );
document.body.i nnerHTML = page;
}
}
</script>
</head>
<body onload="MyHead( )">


almost works! if i change repl to a different word, it will work (it will
display another word), but if i use that img tag, nothing changes.


ahh, think i got it! i had to change my quotes in the img tag to single
quotes.

is find a special variable? if i wanted to find and replace some other
words, how could i do that without making a bunch more functions?

thank you very much.

Jul 23 '05 #7

juglesh wrote:
Hello,

I need to look through the text on a page and replace certain words with an image or other word

something like:

read document
find all instances of the word "blah"
change all instances of the word "blah" to <img src="MyPicture. jpg" >

(jeez, I don't get why computers cant just read english!<G>)
and, no, I cant just change the page with 'find/replace' in notepad.

--
thanks,
juglesh B>{)}

Maybe...

http://www.alistapart.com/articles/dynatext/

Jul 23 '05 #8
"juglesh" <ju*****@nospam RadioKDUG.com> wrote in message
news:cP1yd.3037 59$R05.64258@at tbi_s53...

[snip]

ahh, think i got it! i had to change my quotes in the img tag to single
quotes.

is find a special variable? if i wanted to find and replace some other
words, how could i do that without making a bunch more functions?

thank you very much.

"var find" and "var repl" are just variable names.
Jul 23 '05 #9
"juglesh" <ju*****@nospam RadioKDUG.com> wrote:
read document
find all instances of the word "blah"
change all instances of the word "blah" to <img src="MyPicture. jpg" >

(jeez, I don't get why computers cant just read english!<G>)


Well, it nearly looks like Applescript, which has a syntax like

tell application "Finder" to set x to entire contents of folder
"Macintosh HD:System Folder"

:-)
Jul 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1360
by: bateman | last post by:
Hi, what I am trying to do is the following, its causing some probs though: I have the following in a database: ] This is just some dummy text. It doesn't mean anything and is for placeholding use only. And want to change it to: <div class="imagediv"><img src="/images/100.jpg" alt="100.jpg" width="200" height="200" /><br />
3
1765
by: Andy | last post by:
Can someone please help me with this problem? I don't know if this is possible in Java, so if it's not please point me in the right direction or to the right newsgroup! (I'm a newby to Java scripting). On a web page I have a webcam type image that updates every minute. I wish to conditionally replace this image with an apology image in the event that my upload fails for more than an hour. I guess what I want is some script that will...
3
8891
by: gregpinero | last post by:
I'm trying to write a little script that will have a list of word pairs which will loop through that list and replace all instances of each word with the other word. I'm very new to javascript so I'm not quite sure where to get started. Here is my python "prototype" in case you want a better idea of what I'm trying to do: <code> corpus="""
6
7285
by: Dan V. | last post by:
What is the best/simplest way to have a large top image with let's say 14 thumbnails under it in 7 rows and to replace the top image with the larger one when a user clicks on a thumbnail? I would prefer to only have one html page. thanks,
12
2611
by: Charlie King | last post by:
As I understand it, the use of FIR* to replace heading tags with images in visually enabled CSS browsers is now frowned upon on the basis that some screen readers will *nor* read back text that is marked up by CSS to be invisible or hidden. So... If I want to replace headings with images (because my client wants to use his specific font for headings where possible), what's the best way to do it?
3
2486
by: gregpinero | last post by:
Hi guys, What I'm trying to do is find all instances of an acronymn such as IBM on a webpage and replace it with <acronym title="International Business Machines">IBM</acronym>. However in my code below it replace the <, and > with &lt; and &gt;. Thus it replaces IBM with: &lt;acronym title="International Business Machines"&gt;IBM&lt;/acronym&gt;
6
5894
by: Martin Evans | last post by:
Sorry, yet another REGEX question. I've been struggling with trying to get a regular expression to do the following example in Python: Search and replace all instances of "sleeping" with "dead". This parrot is sleeping. Really, it is sleeping. to This parrot is dead. Really, it is dead.
18
2474
by: Umesh | last post by:
Do you have any answer to it? thx.
1
3390
by: neovantage | last post by:
Hey all, I am using a PHP script which creates headings at run time in a sense at page execution. I am stuck a with a very little problem which i am sure i will have the solution from experts. The problem is when it creates transparent PNG format image then and it pixel ate the image. e.g. If i am using a gradient in background then it vary in color range. Now when i used that php script it generates image successfully but it pixel ate...
0
8795
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8701
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9168
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9009
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7942
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4715
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3155
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2510
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2103
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.