473,387 Members | 1,520 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,387 software developers and data experts.

Problem: Setting MSIE iframe innerHTML change relative href/src to absolute href/src

I am working on a web-based html editor using MSIE's designmode and
iframes.

Everything works just fine, but MSIE changes all my relative "a href"
and "img src" links (i.e. "/index.asp") to absolute links (i.e.
"http://localhost/index.asp") when I set the iframe's innerHTML.

This is bad as the links are supposed to be relative. How can I avoid
this? Any solutions/suggestions are much appreciated.

- This (setting the innerHTML) works just fine in Mozilla/Netscape.

- I have tried to create a selection/range and use "pasteHTML" instead
but the result is the same.

- I have tried to set the "html head base href" in the initial
document loaded by the iframe but the result is the same.
Example:

myiframe.contentWindow.document.body.innerHTML = '<a
href="/index.asp">xxx</a>';
alert(myiframe.contentWindow.document.body.innerHT ML);

Output:

<a href="http://localhost/index.asp">xxx</a>
Jul 20 '05 #1
5 21584
Soren Vejrum wrote on 05 jul 2003 in microsoft.public.scripting.jscript:
I am working on a web-based html editor using MSIE's designmode and
iframes.

Everything works just fine, but MSIE changes all my relative "a href"
and "img src" links (i.e. "/index.asp") to absolute links (i.e.
"http://localhost/index.asp") when I set the iframe's innerHTML.

This is bad as the links are supposed to be relative. How can I avoid
this? Any solutions/suggestions are much appreciated.

- This (setting the innerHTML) works just fine in Mozilla/Netscape.

- I have tried to create a selection/range and use "pasteHTML" instead
but the result is the same.

- I have tried to set the "html head base href" in the initial
document loaded by the iframe but the result is the same.
Example:

myiframe.contentWindow.document.body.innerHTML = '<a
href="/index.asp">xxx</a>';
alert(myiframe.contentWindow.document.body.innerHT ML);

Output:

<a href="http://localhost/index.asp">xxx</a>


You have a iframe that is not filled by an html file, but by innerHTML.

Such "file" has no location so it cannot have relative links !!!

So either it makes it's own absolute links or it does not wort.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #2
Evertjan. wrote on 05 jul 2003 in microsoft.public.scripting.jscript:
or it does not wort.


"or it does not work."

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #3
Thanks, but the iframe is actually created in an html file with a dummy html
file (with html, head, title, style sheet and body tags) loaded for the
iframe before I try to replace the innerHTML.

In the meantime I have found a "hack" to circumvent this "error". I can
replace the iframe body content through "write":

myiframe.contentWindow.document.write('<a href="/index.asp">xxx</a>');

However, I think this is ugly and would prefer to do this through the DOM if
at all possible.
Jul 20 '05 #4
Soren Vejrum wrote on 05 jul 2003 in comp.lang.javascript:
Thanks, but the iframe is actually created in an html file with a
dummy html file (with html, head, title, style sheet and body tags)
loaded for the iframe before I try to replace the innerHTML.

In the meantime I have found a "hack" to circumvent this "error". I
can replace the iframe body content through "write":

myiframe.contentWindow.document.write('<a
href="/index.asp">xxx</a>');

However, I think this is ugly and would prefer to do this through the
DOM if at all possible.


First who will see the "uglyness" ?

Could you have javascript in the iframe file FETCH the value from the
parent instead of having the parent sending it to the file ?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #5
"Soren Vejrum" <ve****@doek.dk> writes:
In the meantime I have found a "hack" to circumvent this "error". I can
replace the iframe body content through "write":

myiframe.contentWindow.document.write('<a href="/index.asp">xxx</a>');

However, I think this is ugly and would prefer to do this through the DOM if
at all possible.


It is (almost) DOM.

The "write" method of the HTMLDocument interface is part of DOM 2 HTML
(except that the DOM expects the document stream to have been openend
by the "open" function first).

The "contentWindow" property is not DOM 2, but the "contentDocument"
property is, and is understood by Mozilla and Opera (but not IE, ofcourse).
The "contentWindow" property is understood by Mozilla and IE, but should
be equivalent to "frames['iframeName']" anyway.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #6

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

Similar topics

4
by: Federico Bari | last post by:
Good morning all from italy, i have probably a compatibility problem with a html/javascript page. The aim of the code of the file test.htm you find here following (copy the 3 files in the...
4
by: JesusFreak | last post by:
From: us_traveller@yahoo.com (JesusFreak) Newsgroups: microsoft.public.scripting.jscript Subject: toolbar script problem NNTP-Posting-Host: 192.92.126.136 Recently, I downloaded the following...
1
by: Martial Spirit | last post by:
Hello- I was amazed at the suckerfish drop-downs from AListApart.com. They work great except for one thing, if I position the drop-downs over an iframe element, on mouseover the menus disappear....
8
by: rdlebreton | last post by:
Hi, Folks! I've been trying to develop my own version of these draggable layers and I have been limiting myself to IE6...for now. I have looked at some other examples to get ideas of creating...
1
by: William Starr Moake | last post by:
Another problem with absolute paths in the WYSIWYG editor I'm putting together. The function to toggle between WYSIWYG and HTML modes works except for one glitch. If you use a relative path for...
5
by: Mel | last post by:
i need to have 2 side by side iframes, a link on top of the one will show/hide the other can someone help me pleeeeezzzzz ?
2
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button...
1
by: wenijah | last post by:
Hi everyone! First thank you for reading this post and yes, you probably already see that kind of topic title somewhere but the problem I've got today might be different than the 100 topics I've...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.