473,406 Members | 2,259 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

avoid innerHTML parsing

I need to create element with some content inside. This may be any
HTML stuff - tags, text. I do next

Set newelem = doc.createElement("span")
newelem.innerHTML = "<a href=""test\test.htm"">1st</a>"

(code above is written in VB, but it does not matter)

but in saved HTML I have anchor with absolute path
<a href="file:///c:/test/test.htm">1st</a>

All I want is avoiding internal parsing of innerHTML. I found, that I
can
set anchor.href directly and it will not be parsed. But I need to
parse string with element and find "href" substring. This seem to be a
buggy way.
I prefer to do it with no workarounds, with some simple and bugs-free
way.
Is there any chance for that?
Jul 20 '05 #1
1 6651


Sergey Batishchev wrote:
I need to create element with some content inside. This may be any
HTML stuff - tags, text. I do next

Set newelem = doc.createElement("span")
newelem.innerHTML = "<a href=""test\test.htm"">1st</a>"

(code above is written in VB, but it does not matter)

but in saved HTML I have anchor with absolute path
<a href="file:///c:/test/test.htm">1st</a>

All I want is avoiding internal parsing of innerHTML. I found, that I
can
set anchor.href directly and it will not be parsed. But I need to
parse string with element and find "href" substring. This seem to be a
buggy way.
I prefer to do it with no workarounds, with some simple and bugs-free
way.
Is there any chance for that?


Try
var link = document.createElement('a');
a.href = 'test/test.html';
span.appendChild(a)
I don't see any reason to mix createElement with innerHTML assignment
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2

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

Similar topics

8
by: Kyle | last post by:
I am presently making use of documentElement.innerHTML to retrieve page contents for manipulation, but I've noticed that the sting value returned is not identical to the actual page source....
11
by: kaeli | last post by:
Hey all, AFAIR, innerHTML started as MS proprietary, but Mozilla implemented it as well. Does anyone know if any other browsers support it? It is not in the W3C DOM, is it? A quick GIS seemed to...
3
by: Ralph Snart | last post by:
i've read that innerHTML is not in the W3C standards and never will be. however i've found something that i simply can't do by manipulating text nodes directly. <div id="mydiv"></div> <script...
6
by: wk | last post by:
i have a <table></table> ...and the have a string with the html that will create the table rows, columsn etc....perhaps <tr><td>a row</td></tr>. this string comes dynamically from a source and...
17
by: PJ | last post by:
Greetings... I have stumbled upon a small problem. I use Ajax to retrieve part of a page I need to update. I update a DIV element with the HTML contents I get from another page. It works...
8
by: Pratik Patel | last post by:
Hello, I used innerHTML to assign HTML content. but in my HTML page content have also some javascript function and it will run when page load. bu when HTML code assgin thru innerHTML then this...
11
by: EnjoyNews | last post by:
Hi I just had a thought regarding spam... I have noticed that when I do something in JavaAjax then I can't se the context in the source. .... If I open a page in a div with Ajax, right click...
6
by: PaPa | last post by:
I'm not sure this is a javascript issue or an HTML issue. I notice that when I extract the contents of a div using the innerHTML property (?), that I wind up with a literal variable (?) which...
0
by: samz | last post by:
Hello, Here is a simple PHP recursive file list (with interactive and visual FX) Sam's Files http://acc.jexiste.ch/JPN/RecurciveDIR12.RAR 1. How to ignore/avoid empty folders in this PHP script...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...

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.