473,732 Members | 2,204 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.conten tWindow.documen t.body.innerHTM L = '<a
href="/index.asp">xxx</a>';
alert(myiframe. contentWindow.d ocument.body.in nerHTML);

Output:

<a href="http://localhost/index.asp">xxx</a>
Jul 20 '05 #1
5 21630
Soren Vejrum wrote on 05 jul 2003 in microsoft.publi c.scripting.jsc ript:
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.conten tWindow.documen t.body.innerHTM L = '<a
href="/index.asp">xxx</a>';
alert(myiframe. contentWindow.d ocument.body.in nerHTML);

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.publi c.scripting.jsc ript:
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.conten tWindow.documen t.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.javas cript:
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.conten tWindow.documen t.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.conten tWindow.documen t.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 "contentWin dow" property is not DOM 2, but the "contentDocumen t"
property is, and is understood by Mozilla and Opera (but not IE, ofcourse).
The "contentWin dow" 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
4764
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 same directory) is to change the content of a layer, created with the <div...> tag, with an external text (clicking over an hiperlink) or with the result of a <form...> submition. The solution (I haven't been able to find anyone else) is to use a...
4
3842
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 beautiful script "http://javascript.internet.com/navigation/toolbar-menu.html". It works like a charm. I made my webpage in frames, where the nav-frame shows the menubar, so whenever I click a link in the menubar, it opens in the frame below. But...
1
4685
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. It works fine in IE, but not FireFox. I would like to implement these menus, but if I can't get this to work, I gotta look at something else. If anyone has some suggestions, I would appreciate it.
8
2568
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 an alternative to pop-up windows in a web page. The code I have works (sort of). The problem is that I can move these layers around when I move the mouse slowly, however, if I move it fast the web browser looses track of the motion and leaves the...
1
3112
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 a link, like <a href="download.htm">Click Here</a>, the editor returns an absolute path the second time you toggle HTML mode: <a href="C:\Windows\Desktop\Editor\download.htm" and even adds file:/// on the third try. This path must be manually...
5
35565
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
3156
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 then the calender gone actually i want if i click outside off the calender then it should me removed ..How kan i do this ... Pls inform me as early as possible .. I am waiting for ur quick replay ...Here i attached the source code .... <!DOCTYPE...
1
3191
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 seen so far that did not resolve my problem... Environment and problem: I have a page A with Ajax.js and a <div id="ajx">Content</div> that changes when clicking on a link. Another page, page B, gets loaded into page A and (tries) to load a...
0
8946
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
8774
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
9307
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...
1
9235
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9181
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
8186
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
6735
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...
2
2721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2180
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.