Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

View Source Link - How? 11

Status
Not open for further replies.

JennyW

Technical User
Mar 1, 2001
323
CA
Hiee, long time no writey.

I wanted to create a link that “Views the source code”.
Does anyone know how to make a link do this?

Here’s my attempt at it…

<a href=&quot;view-source: isn’t a real page.com</a>

Thanks people,
Jenny
 
sorry to double post but this is the link on your site

<a href=&quot;javascript:viewThis('file:///C|/My Documents/006 - html testing/Root Folder for html testing/0008l_dhtml_poll.html')&quot;;>Internal Page's source code</a>

there is your problem.

Manic -----------------------------
I've broken it again !!
-----------------------------
 
Hi Manic,
What's the problem with that?

Thanks,
Jenny
 
manic if you copied pasted then the error, then it's not the path, it's that you wrote viewThis instead of viewSource
 
or..you can just shove the html in a text file, then open it...

-Greg :-Q
 
Hiee,
I tried your idea mackey333 and it worked nicely. Thanks!

However, I still don't know what my problem is with the following...


<a href=&quot;javascript:viewThis('file:///C|/My Documents/006 - html testing/Root Folder for html testing/0008l_dhtml_poll.html')&quot;;>Internal Page's source code</a>


Thanks,
Jenny
 
This worked for me:

<a href=&quot;view-source:file:///C|/My%20Documents/006%20-%20html%20testing/Root%20Folder%20for%20html%20testing/0008l_dhtml_poll.html&quot;;>Internal Page's source code</a>
 
I also checked your website and the second link worked for me also... It has to be a path problem or a typo or something of that sort. Triple-check your folder names and try it again...
 
You could make it generic in nature, any page where it is placed shows the code for that particular page.

Code:
<html>

<head>
<title>View Source</title>

<script language=&quot;Javascript&quot;>
<!--

function viewSource() {
document.location = &quot;view-source:&quot; + document.location.href
}

//-->
</script>

</head>

<body>

<a href=&quot;javascript:viewSource()&quot;;>View Source Code</a>

<form name=&quot;viewSource&quot;>
<input type=&quot;button&quot; name=&quot;source&quot; onclick=&quot;viewSource()&quot; value=&quot;View Source Code&quot;>
</form>

</body>

</html>

I added a link and a button because I didn't know which one you preferred. » » » » » »
Mike Barone
FREE and Pro CGI/Perl Scripts

FREE Scripts
 
jenny, mike's script is also fine for this
just add a parameter to the function :
<script language=&quot;Javascript&quot;>
<!--
function viewSource(which_page) {
document.location = &quot;view-source:&quot; + which_page
}
//-->
</script>

where which_page looks like &quot;nextone.htm&quot;
see ?
 
Wanna see something really cool!

Code:
<html>

<head>
<title>View Source</title>

<script language=&quot;Javascript&quot;>
<!--
function viewSource() {
var test = document.viewSourceXXX.source1.value;
document.location = &quot;view-source:&quot; + test
}
//-->
</script>


</head>

<body>


<form name=&quot;viewSourceXXX&quot;>
<input type=&quot;text&quot; name=&quot;source1&quot;>
<input type=&quot;button&quot; onClick=&quot;viewSource()&quot; value=&quot;View Source&quot;>
</form>

</body>

</html>
» » » » » »
Mike Barone
FREE and Pro CGI/Perl Scripts

FREE Scripts
 
Not bad!
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top