Networking | Hardware | Software | Multimedia | System | Unix&Linux | MBA

Home>>Hardware>>Mimick "View Source" with JavaScript

Mimick "View Source" with JavaScript

jakerbug
01-08-2006, 07:19 PM
I posted this in PHP too because I'll probably need some on both to help figure it out... and before anyone suggests it, view-source:(THE URL) just does not work in the newer versions of IE...

I want to be able to output the exact source code that I see when I click "View Source" directly onto the page I'm looking at. I've been trying for DAYS and I can't get it. Is it possible?

The goal is to have a user review the dynamically generated page they are looking at and then use "fopen" to take the source code from that page and create a static "index.html" file. I just can't figure out any good way with PHP, JavaScript (innerHTML???), or even XML (httprequest), or any combination of those.

I'm thinking if I can get that code exactly how it appears in the "View Source" or an "httprequest" into a text box on my page somehow, I'd be set to then pull the text from that text box and create the file with PHP. Am I that far off?

It seems to me like this should be relatively easy, but I'm so far off in the wrong direction that I don't even know where I went wrong.

felgall
01-08-2006, 09:32 PM
Why not just insatall a view-source bookmarklet in your browser. Then you can select that from the favorites/bookmarks menu to view the source of any page. http://javascript.about.com/library/blsource.htm

Alternatively the following user script installed into Internet Explorer (with Turnabout plugin), Firefox (with Greasemonkey extension), or Opera will add a "Source" link to the bottom of all web pages on the web to allow you to click and view the source of any web page easily.

// ==UserScript==
// @namespace http://javascript.about.com
// @author Stephen Chapman
// @name View Source Link
// @description Adds a View Source link to the bottom of all web pages
// @include *
// ==/UserScript==

// This script (tested in both Firefox/Greasemonkey and Opera) will add a
// View Source link to the bottom of ALL web pages in the included domains.
// This will aid you in your web page development as it shows the HTML the
// way that the browser currently sees it and so enables you to easily see
// the effects of running a Javascript to update the HTML.

var a = document.createElement("a");
a.style.color = "#cccccc";
a.style.backgroundColor = "#666666";
a.style.textDecoration = "none";
a.style.fontSize = "70%";
a.href = "javascript:c=unescape(document.documentElement.innerHTML);c=c.replace(/&/g,'&amp;amp;');c=c.replace(/</g,'&amp;lt;');c=c.replace(/>/g,'&amp;gt;');document.write('<html><head><title>Source of Page</title></head><body><div align=\"center\"><a href=http://codingforums.com/archive/index.php/\"#\" onclick=\"history.back();return false;\">Back</a></div><pre>' + c + '</pre></body></html>');";
a.appendChild(document.createTextNode('Source'));
document.body.appendChild(a);


 

TOP

Hyperthreading hurts s
HP sharpens blade PC l
Apple goes for Quad po
Itanium gets scaled do

For more info

Hyperthreading hurts s
HP sharpens blade PC l
problem with an ImageP
Modifying a navigation
convert text to intege
Anyone knows to clear 
Automatically generate
document.getElementByI
Hi question about stor
Netscape Problems :-( 

News Archive

Month and Year drop do
navigation button/imag
doubt in window.open()
undo redo script 
Mimick "View Source" w
print Question 
No-image representatio
What's wrong with this
Urgent help in Javascr
Gurt Menu assistance 

Related stories:

Month and Year drop down selection boxes
navigation button/image
doubt in window.open()
undo redo script
print Question
No-image representation

Copyright@2004-2005 www.zzcoke.com All Right Reserved

advanced web statistics