473,387 Members | 1,528 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.

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 1909


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.javascript:
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.com/groups?th=693cf051b8e70a91>

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:'<code><ol><li>'+(document.documentElem ent||document.body).outerH
TML.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/ /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.javascript 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
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...
5
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...
8
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...
15
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
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
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....
10
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...
4
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...
0
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...
0
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...
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
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.