473,793 Members | 2,742 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

view source

shr
Is there any way by which I can display the source of a html page
using the 'view:source' command, in an iframe??
I tried using this
viewer.location = "view-source:" + viewer.location .href;
where viewer is an iframe.
but it opens the source in a notepad.

Instead of the source getting displayed in the notepad, I would like
the iframe to display the source.

Thanks in advance
Jul 23 '05 #1
6 1942


shr wrote:
Is there any way by which I can display the source of a html page
using the 'view:source' command, in an iframe??
I tried using this
viewer.location = "view-source:" + viewer.location .href;
where viewer is an iframe.
but it opens the source in a notepad.

Instead of the source getting displayed in the notepad, I would like
the iframe to display the source.


You could use server-side scripting to serve the page with the HTTP header
Content-Type: text/plain
instead of the associatd text/html but IE is known to try to sniff the
content and ignore that. Client-side script is not going to help, at
least not across browsers.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
shr wrote on 29 sep 2004 in comp.lang.javas cript:
Is there any way by which I can display the source of a html page
using the 'view:source' command, in an iframe??
I tried using this
viewer.location = "view-source:" + viewer.location .href;
where viewer is an iframe.
but it opens the source in a notepad.

Instead of the source getting displayed in the notepad, I would like
the iframe to display the source.


<http://groups.google.c om/groups?th=693cf 051b8e70a91>

for IE, because that was on a jscript group.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)

Jul 23 '05 #3
Ivo
"Martin Honnen" wrote
shr wrote:
Instead of the source getting displayed in the notepad, I would like
the iframe to display the source.


You could use server-side scripting to serve the page with the HTTP header
Content-Type: text/plain
instead of the associatd text/html but IE is known to try to sniff the
content and ignore that. Client-side script is not going to help, at
least not across browsers.


This bookmarklet writes the generated source in the page, you could turn it
into a regular function:

javascript:'<co de><ol><li>'+(d ocument.documen tElement||docum ent.body).outer H
TML.replace(/&/g,"&amp;").repl ace(/</g,"&lt;").repla ce(/ /g,"&nbsp;
").replace(/\n/g,"<li>")+'<\/ol><\/code>';

The the downloaded source and the generated source may differ significantly.
You can get the first one in a variable with the XML HTTP Request object.
See
<URL: http://jibbering.com/2002/4/httprequest.html >
--
Ivo
Jul 23 '05 #4
Martin Honnen wrote:
shr wrote:
Is there any way by which I can display the source of a html page
using the 'view:source' command, in an iframe??
[...]
Instead of the source getting displayed in the notepad, I would like
the iframe to display the source.


You could use server-side scripting to serve the page with the HTTP header
Content-Type: text/plain
instead of the associatd text/html but IE is known to try to sniff the
content and ignore that. Client-side script is not going to help, at
least not across browsers.


However, if server-side scripting is available, ways are available
to convert "<" to "&lt;" and ">" to "&gt;". Not even IE will try
to parse the content then. The document must be served as text/html
(or application/xhtml+xml) with a surrounding "body" element, though.
The "pre" element should come in handy then.
PointedEars
--
If there were no BUGs........... .we wouldn't have our jobs!
Jul 23 '05 #5
Thomas 'PointedEars' Lahn wrote:
However, if server-side scripting is available, ways are available
to convert "<" to "&lt;" and ">" to "&gt;". Not even IE will try
to parse the content then. The document must be served as text/html
(or application/xhtml+xml) with a surrounding "body" element, though.
The "pre" element should come in handy then.


Or, much more simple, if server-side PHP is available and the file is
on an ext2 compatible filesystem, one could place a symlink with the
suffix .phps to point to the .html file (if the filesystem is not
ext2 compatible, a renamed copy of the .html file is required). PHP
will then output the color-coded source code if used as an Apache
module, the Apache configuration contains

AddType application/x-httpd-php-source .phps

and the .phps file is accessed as HTTP resource. Example:

<http://www.pointedears .de/scripts/test/dom.xhtml.phps>
PointedEars
--
"I have the heart of a small boy -- and I keep it in a jar on my desk."
Jul 23 '05 #6
Thomas 'PointedEars' Lahn wrote:
Thomas 'PointedEars' Lahn wrote:

However, if server-side scripting is available, ways are available
to convert "<" to "&lt;" and ">" to "&gt;". Not even IE will try
to parse the content then. The document must be served as text/html
(or application/xhtml+xml) with a surrounding "body" element, though.
The "pre" element should come in handy then.

Or, much more simple, if server-side PHP is available and the file is
on an ext2 compatible filesystem, one could place a symlink with the
suffix .phps to point to the .html file (if the filesystem is not
ext2 compatible, a renamed copy of the .html file is required). PHP
will then output the color-coded source code if used as an Apache
module, the Apache configuration contains

AddType application/x-httpd-php-source .phps


Since you bring it up, that extension can be just about anything you
want it to be, including - but not limited to - phps. Personally, I use
the extension .source instead of phps which can be misleading.
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq
Jul 23 '05 #7

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

Similar topics

2
7296
by: Gary DeRousse | last post by:
Hello, Using SQL Server 2000, I'm trying to put together a query that will tell me the following information about a view: The View Name The names of the View's columns The names of the source tables used in the view The names of the columns that are used from the source tables Borrowing code from the VIEW_COLUMN_USAGE view, I've got the code
5
7213
by: Pete Wason | last post by:
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.
8
2892
by: Nancy | last post by:
Hi, Guys, I don't know why I can't view some webpages source code by click "View->Source" menu of Browser. These webpage source code can be viewed in same way by using other computers. My OS is Win Xp and Browser is IE6.0. I don't use any fire wall. Appreciate any hint. Nancy
15
3017
by: Michael Hill | last post by:
I saw a site that looked pretty good, but I could view the source. 2 questions: 1) how can I do the same for my site 2) any way to get around this? Mike
18
2559
by: Lorem Ipsum | last post by:
interesting! I just found a page in which Explorer's View Source does nothing! How did they do that?
8
2246
by: Alvo von Cossel I | last post by:
hey everybody, I have written a great browser but it is missing a feature (quite a lot actually, but forget about them for now). that feature just so happens to be the View > Source function. for those of you who don't what i mean, it is when you click a button in the view menu that says Page source (in Netscape) and source (in Internet Explorer). if you click it, notepad opens. in that window is the html for the page. anyway, does...
10
2532
by: dwok | last post by:
Does anyone know of a good article that discusses creating a "Tree View" control in ASP.NET? Or perhaps a Tree View Control that comes with source code? I have come across a lot of tree controls for ASP.NET however most of them are already compiled and don't come with source code. I am really just looking for an example on how to create my own Tree Control. Thanks a bunch.
4
2929
by: steph | last post by:
Hi, A question regarding Access 2002: I've got a form which should be displayed in Form View and in Datasheet View. But I want to use a different record source for each view. That means, when the view is switched I want to switch the record source also. I tried to put this functionality on the "On View Change" event, but
0
1320
by: Don | last post by:
I have a page that has several controls on it and the controls are shown or hidden during postback. I show and hide them using the visible property. When I use 'view source' in Internet Explorer I always see the source of the first version of the page, with the controls rendered that where rendered on the first visit. The changes that occur during postback are not reflected in 'view source'. Example Detail: My page has 6 controls and...
0
2400
by: Jacob Donajkowski | last post by:
Once the user logs in I want to have the users switch from the Roster View to the Profile View and enter their profile infomation and save it. Then the next time they login and go to the Profile View I want the form populated from there profile on the sql server. The code to save the profile works fine. But when the user logs back in they data doesn't load back to the form. The multiview is located inside the LoginView's Logged-In View ....
0
9671
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
9518
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
10433
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
10000
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...
1
7538
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
6777
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
5436
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
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4112
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

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.