473,765 Members | 2,121 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IFRAME, view-source: for a page not loaded

Hiall!

I have a demo viewer page for javascript stuff that has three buttons "DEMO"
"HTML" and "JSCR", and an IFRAME called 'viewer'.

Initially, the IFRAME gets loaded with the actual demo page, ie.,

viewer.location = dName + '.html';

where dName is the filename of the demo without extension.

Clicking on "HTML" replaces the IFRAME contents like this:

viewer.location = "view-source:" + viewer.location .href;

And Clicking on "JSCR" replaces the IFRAME contents like this:

viewer.location = dName + '.js';

These all work OK by themselves - at least at first. The problem comes when I
Click "JSCR" to display the appropriate .js file, and then click "HTML" to go
back to the source of the HTML file: I just get the .js file again (and it's
fairly obvious why).

I tried doing this in the "HTML" click:

viewer.location = dName + '.html';
viewer.location = "view-source:" + viewer.location .href;

attempting to reload the demo page before showing its source, but this doesn't
work very well - I have to click "HTML" 2 or 3 times to get the source to
appear (because, I think, both these lines need the function to return before
anything really happens visually).

In a nutshell:

How I can view (in an IFRAME) the source of an html page which is not the
IFRAME's current document.locati on?

TIA
Pete
Jul 20 '05 #1
5 7211
Pete Wason wrote:
Hiall!

I have a demo viewer page for javascript stuff that has three buttons
"DEMO" "HTML" and "JSCR", and an IFRAME called 'viewer'.

Initially, the IFRAME gets loaded with the actual demo page, ie.,

viewer.location = dName + '.html';

where dName is the filename of the demo without extension.

Clicking on "HTML" replaces the IFRAME contents like this:

viewer.location = "view-source:" + viewer.location .href;

And Clicking on "JSCR" replaces the IFRAME contents like this:

viewer.location = dName + '.js';

These all work OK by themselves - at least at first. The problem comes
when I Click "JSCR" to display the appropriate .js file, and then click
"HTML" to go back to the source of the HTML file: I just get the .js
file again (and it's fairly obvious why).

I tried doing this in the "HTML" click:

viewer.location = dName + '.html';
viewer.location = "view-source:" + viewer.location .href;

attempting to reload the demo page before showing its source, but this
doesn't work very well - I have to click "HTML" 2 or 3 times to get the
source to appear (because, I think, both these lines need the function
to return before anything really happens visually).
You have a timing issue. When you set its location to dName + '.html';,
and then set it to view-source, it hasnt had time to load the page so
you see what was already there - the .js source. Look into the
readyState property of the IFrame. Then, when its loaded, show its source.
In a nutshell:

How I can view (in an IFRAME) the source of an html page which is not
the IFRAME's current document.locati on?


Another, maybe better, solution would be to use 2 IFrames, 1 is hidden.
IFrame1 would be hidden and contain the HTML file.

When you clicked, instead of setting it to the view-source of its own
location.href, you set it to display view-source: of the hidden frames
href property.

Then, to display the .js, you set it to the dName + '.js';

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq/

Jul 20 '05 #2
Ivo
"Randy Webb" <hi************ @aol.com> wrote in message
news:t_******** ************@co mcast.com...
Pete Wason wrote:
I tried doing this in the "HTML" click:

viewer.location = dName + '.html';
viewer.location = "view-source:" + viewer.location .href;


You have a timing issue. When you set its location to dName + '.html';,
and then set it to view-source, it hasnt had time to load the page so
you see what was already there - the .js source. Look into the
readyState property of the IFrame. Then, when its loaded, show its source.
In a nutshell:

How I can view (in an IFRAME) the source of an html page which is not
the IFRAME's current document.locati on?


Another, maybe better, solution would be to use 2 IFrames, 1 is hidden.
IFrame1 would be hidden and contain the HTML file.

When you clicked, instead of setting it to the view-source of its own
location.href, you set it to display view-source: of the hidden frames
href property.


I don't believe it. Whenever I view-source:http://etc. I get the source
presented in Notepad, no matter how many windows, frames and iframes I have
open. How do you get it to display in the browser??
Also, the page that I 'm viewing the source does not need to be loaded in
any browser (though it helps speed-wise) as far as I am aware.
Ivo
Jul 20 '05 #3
Ivo wrote:
"Randy Webb" <hi************ @aol.com> wrote in message
news:t_******** ************@co mcast.com...
Pete Wason wrote:
I tried doing this in the "HTML" click:

viewer.location = dName + '.html';
viewer.location = "view-source:" + viewer.location .href;


You have a timing issue. When you set its location to dName + '.html';,
and then set it to view-source, it hasnt had time to load the page so
you see what was already there - the .js source. Look into the
readyState property of the IFrame. Then, when its loaded, show its source.

In a nutshell:

How I can view (in an IFRAME) the source of an html page which is not
the IFRAME's current document.locati on?


Another, maybe better, solution would be to use 2 IFrames, 1 is hidden.
IFrame1 would be hidden and contain the HTML file.

When you clicked, instead of setting it to the view-source of its own
location.href , you set it to display view-source: of the hidden frames
href property.

I don't believe it. Whenever I view-source:http://etc. I get the source
presented in Notepad, no matter how many windows, frames and iframes I have
open. How do you get it to display in the browser??
Also, the page that I 'm viewing the source does not need to be loaded in
any browser (though it helps speed-wise) as far as I am aware.
Ivo


What browser are you using? Netscape 7.1 here... standard Mozilla behaviour,
which is to say, standards-compliant behaviour. I never use IE unless a page
forces me to (bad page! no biscuit!), so I don't know (or, in general, care)
how it interprets view-source:

document.locati on = "view-source:" + document.locati on.href;

Seems to work fine, as long as the page you want to see the source of is
already loaded.

Pete

Jul 20 '05 #4
Ivo
"Pete Wason" <ro***@hynoom.c om> wrote in message
news:10******** *****@corp.supe rnews.com...
Ivo wrote:
"Randy Webb" <hi************ @aol.com> wrote in message
news:t_******** ************@co mcast.com...

Whenever I view-source:http://etc. I get the source
presented in Notepad, no matter how many windows, frames and iframes I have open.
What browser are you using? Netscape 7.1 here... standard Mozilla behaviour, which is to say, standards-compliant behaviour. I never use IE unless a page forces me to (bad page! no biscuit!), so I don't know (or, in general, care) how it interprets view-source:

document.locati on = "view-source:" + document.locati on.href;

Seems to work fine, as long as the page you want to see the source of is
already loaded.

Pete


I just typed in my IE addressbar

view-source:http://www.nytimes.com/

and up popped the code. Since I have not been there in a while and it
contains today's news, I can be sure it isn't a cached copy.
Fwiw,
Ivo
Jul 20 '05 #5
Ivo wrote:
"Randy Webb" <hi************ @aol.com> wrote in message
news:t_******** ************@co mcast.com...
Pete Wason wrote:
I tried doing this in the "HTML" click:

viewer.location = dName + '.html';
viewer.location = "view-source:" + viewer.location .href;

You have a timing issue. When you set its location to dName + '.html';,
and then set it to view-source, it hasnt had time to load the page so
you see what was already there - the .js source. Look into the
readyState property of the IFrame. Then, when its loaded, show its source.

In a nutshell:

How I can view (in an IFRAME) the source of an html page which is not
the IFRAME's current document.locati on?


Another, maybe better, solution would be to use 2 IFrames, 1 is hidden.
IFrame1 would be hidden and contain the HTML file.

When you clicked, instead of setting it to the view-source of its own
location.href , you set it to display view-source: of the hidden frames
href property.

I don't believe it. Whenever I view-source:http://etc. I get the source
presented in Notepad, no matter how many windows, frames and iframes I have
open. How do you get it to display in the browser??


Can I scratch my head a few more days and try to remember what I screwed
up badly to make it work the first time? Of course, you are right with
regards to view-source.

Personally, if I wanted to show the source of the page in an IFrame,
with IE, I would use an HTTPRequestObje ct to load it and then display it
via IE's innerText property. Probably using a div instead of IFrame though.

A better approach, all around, would be to submit to the server and let
the server get it, return it as plain text and display it though.
Also, the page that I 'm viewing the source does not need to be loaded in
any browser (though it helps speed-wise) as far as I am aware.


No, it doesn't have to be loaded in the browser.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq/

Jul 20 '05 #6

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

Similar topics

5
20632
by: gsb | last post by:
Is there any way to make the background of an iFrame (object) transparent? The iFrame is in a 'floating' DIV and I want the underlying HTML page to show through as a background. Thanks, gsb
6
18718
by: Phlip | last post by:
JavaScripties: On the HTML side, we load an IFRAME with a blank page: <iframe frameborder="0" marginwidth="0" marginheight="0" scrolling="off" src="about:blank" id="iframe_xml1!format_text" name="iframe_xml1!format_text" width="90%" height=" 180 ">Your browser is inferior and doesn't support IFRAMEs.</iframe> Later, a button click populates this frame:
2
2879
by: Robert Oschler | last post by:
I have an IFrame whose document is created completely by Javascript code at runtime. The document in the IFrame accesses Javascript functions in the top level document. This works fine most of the time. But every now and then, when I hit the back button, the browser suddenly thinks the Javascript created document in the IFrame is not from the same domain as the topmost document, and therefore I start getting "permission denied" errors...
0
1420
by: Kenneth Keeley | last post by:
Hi We have an Iframe that displays the contents of a folder. By default the files are shown as large icons. I would like to change this so that the files display as a list of files (ie small icon view). Can this be done and if so how do I do it. Thank you. Kenneth
1
2600
by: mandakini | last post by:
Hello freinds I am working on this url http://72.36.156.243/compbuild.php Here I am using ifram and displaying dynamic value I don't know how to use iframe as array how to assign array and retrive value from array. I am very poore in javascript please help me. coding is like this
0
990
by: Mike P | last post by:
I am using the tree view IE web control and I need to show different iframes depending upon which node in the tree view has been clicked, and if not have been clicking I don't want any iframe to show. Can anybody help me out with this? I don't know how to show/hide iframes, and if this would be the right way to go about it. Thanks
4
3913
Samji
by: Samji | last post by:
Hello everyone. I am trying to write out the contents of a tag in an XML document to an iframe. I can do that successfully with the following code... function constructMsgBody() { // constuct message body from "message" tags; // write out to iframe on view message dialog
4
9859
by: Amuthaangler | last post by:
Hi all, I am currently working with Iframe which holds the JSON response from the server once when the picture gets uploaded successfully. Now I need to parse the JSON response and retrieve the id of the image uploaded. My Iframe is here <iframe id="PUIFrame" name="PUIFrame" style="width:300px; height:200px; border: 5px;" src="blank.html"> </iframe>
4
2290
by: R144N | last post by:
Hi Everyone, I've searched variuos forums as much as I could for a similar problem within the time I could and found no helpful solution, I hope someone here can help me out: I have an iFrame issue in all Mozilla browsers where the text appears to be like strikethrough text but it is definitely a rendering issue. I have tried iFrame and Object tags as advised on w3c.org but alas, the same problem. Is this a bug in Mozilla? and if so, is...
1
3171
by: John L. | last post by:
How do I invoke the scroll() method of a window object for a scrollable IFRAME element in an HTML document? I am using IE 7.0, and I thought the following would work: document.frame01.scroll(x,y) or possibly document.getElementById('frame01').scroll(x,y)
0
9398
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
10156
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9832
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
8831
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
7375
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
6649
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
5275
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...
1
3924
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
3
2805
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.