473,799 Members | 3,422 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using javascript to modify an HTML page?

I know that you can use the javascript document.write( ) method to
inject new content into a page.

Is it possible to _modify_ an HTML page?

For example, say I wanted to go through the current page and change
every <B></B to <I></I>?

Is this possible? If so, how?

Oct 2 '06 #1
3 1765
"William Krick" <wk****@gmail.c omwrote in message
news:11******** *************@k 70g2000cwa.goog legroups.com...
I know that you can use the javascript document.write( ) method to
inject new content into a page.

Is it possible to _modify_ an HTML page?

For example, say I wanted to go through the current page and change
every <B></B to <I></I>?

Is this possible? If so, how?
How does one "inject new content into a page" if it's someone else's
page delivered over the Internet via a Web browser?

What is your purpose and how would you want it to work?

If are viewing an external Web site and want to change tags then you'll
have to download the page, change image and link references, change
the tags, save it locally, then open it up in a browser.

Potentially this could be done via scripting -- like an HTA.

Also, many sites use CSS' "'font-weight:bold" instead of "<b></b>".
Oct 2 '06 #2


William Krick wrote:

For example, say I wanted to go through the current page and change
every <B></B to <I></I>?
var bElements = document.getEle mentsByTagName( 'b');
for (var i = bElements.lengt h - 1; i -1; i--) {
var bElement = bElements[i];
var iElement = document.create Element('i');
bElement.parent Node.replaceChi ld(iElement, bElement);
while (bElement.hasCh ildNodes()) {
iElement.append Child(bElement. firstChild);
}
}
--

Martin Honnen
http://JavaScript.FAQTs.com/
Oct 2 '06 #3

Martin Honnen wrote:
William Krick wrote:

For example, say I wanted to go through the current page and change
every <B></B to <I></I>?

var bElements = document.getEle mentsByTagName( 'b');
for (var i = bElements.lengt h - 1; i -1; i--) {
var bElement = bElements[i];
var iElement = document.create Element('i');
bElement.parent Node.replaceChi ld(iElement, bElement);
while (bElement.hasCh ildNodes()) {
iElement.append Child(bElement. firstChild);
}
}

I haven't tested it yet, but it looks like it should work. Thanks for
your help.

Basically, I'm looking for a better way to deal with the new IE
<OBJECTtag problem. I'm thinking that if I change all the <OBJECT>
tags in my HTML pages to something else like <XOBJECT>, then call the
code above on page load to rewrite all the <XOBJECTtags to <OBJECT>,
it should work.

At least on the surface, it seems like a simpler solution than the
alternatives proposed by Adobe...

http://www.adobe.com/devnet/activeco...devletter.html

Oct 6 '06 #4

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

Similar topics

7
9021
by: Scott | last post by:
I need help to modify the code below to pass url variables from a framset. The click to run this will be in the mainFrame. This script works well in a non-frame page. Grabs the current url variables and adds them to my url. <script type="text/javascript"> //<!]> </script>
7
1985
by: Trvl Orm | last post by:
I am working with 2 frames, Left and Right and the main code is in the left frame, which has been attached. Can someone please help me with this code. I am new to JavaScript and can't figure it out. What needs to happen is this: On the left frame you should have a series of buttons, which when pushed makes things happen on the right frame.
2
2059
by: thinkfr33ly | last post by:
I have a page that inserts a block of javascript dynamically into the page "Test.html". The inserted block, "Block A", then does a document.write of another script block "Block B". This script block does its own document.write of one last script block "Block C". The way this occurs is somewhat out of my control, and I need to find a way to work within this framework. This only needs to work in IE 5.5 or better. My problem is that the...
0
6439
by: Michelle Keys | last post by:
I am trying to call a print function to print a string from a database using javascript. Which is RC_DATA of Varchar2(2500). This is a javascript is not being used. I have a thing that needs to be modified: if(e.CommandName =="Print") { string parsedreceipt = null; parsedreceipt = DecodeReceipt (e.Item.Cells.Text); Session = parsedreceipt;
5
3165
by: Marcel Gelijk | last post by:
Hi, I am trying to create a User Control that is located in a seperate class library. The User Control contains a textbox and a button. The page generates an exception when it tries to access the code variable that are supposed to be linked to the contained controls. It runs fines when everything is contained in a single web form project. What do I need to do to make it work from a class library?
0
974
by: Jim Corey | last post by:
I'm experimenting with a code generator that creates an html page which includes a lot of javascript that modifies (for example) input boxes on the page. I can paste the html into an aspx page, change some input boxes to asp labels and the javascript can still work because the id's for the labels still match the id's that are referenced in the javascript. I'd like to paste the html into an ascx control, but
0
3723
by: Chris Fink | last post by:
My goal is to have an ASP.NET checkbox server tag with it's autopostback set to true, that when clicked will run the checkbox's CheckedChanged event. However, I would like to try to add a javascript confirm popup to this checkbox server control to prevent this event from firing if the cancel button is checked in the js confirm window. In the example below, I am able to accomplish this using the input type=checkbox but without the...
6
4701
by: kelvlam | last post by:
Hello, I'm a new begininer with JavaScript. I'm trying to figure out which is the best approach, and to understand the differences between them. I have a <Aelement that's suppose to either launch a popup window, or it will link you to some dynamic created page. I have declared a global JavaScript function
7
3632
by: pamelafluente | last post by:
The precious input given by Laurent, Martin, Benjamin about XMLHttpRequest in Javascript, has made me think that perhaps I could improve what I am currently doing by using Ajax. Let's make it simple and schematic, to see if there is a simple Ajax answer to this. A. I have an HTML page which has some pure html/css code representing a GRID of cell. The page may also contain other objects (images, etc). B. On the server I have a windows...
3
4105
by: jackson.rayne | last post by:
Hello, Another newbie question here. Let me explain my situation first. I have bought a 3rd party tool that runs a PHP script and gives me some HTML code which I can directly use in my pages. The code generated is normal HTML code, example
0
9688
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
9544
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
10259
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
10030
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
9077
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...
1
7570
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5589
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.