getting source code of a page

This is a discussion on "getting source code of a page" within the JavaScript Forum section. This forum, and the thread "getting source code of a page are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Oct 11th, 2007, 01:44
New Member
Join Date: Oct 2007
Location: US
Age: 38
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
getting source code of a page

Hi, this is my first post (but not last), thanks for reading.


Here's my problem: I want a site with two frames: the left one has a button, and the right one is an external site (eg: google.com).

And I want (need) that when the button in the left frame gets clicked it saves the source code of the site in the right one. I need to get this source in a String or in a file or in some other way that I can manipulate it (I know I can't modify an external page, and that's not what I want)

I did the following code, that works when the left frame is an internal file (ex: frame_02.htm), but does't work when I use http://google.com

Code: Select all
//this the main page
<html>
<title>Exemplo de criação de frames</title>

<FRAMESET cols="50%,50%">

    <FRAME SRC="frame1.htm" NAME="frame1">

    <FRAME SRC="http://google.com" NAME="frame2"> 
//works if was "frame2.htm"

</FRAMESET>
<body></body>
</html>
Code: Select all
//this is frame1.htm
<html>
<title>Frist Frame</title>
<body>

<form name="view">
<input type="button" name="source" onclick="vs()" value="View This Page's Source">
</form>
<script language="Javascript">
<!--
// please keep these lines on when you copy the source
// made by: Nicolas - http://www.javascript-page.com

function vs() {
document.location = "view-source:" + parent.frame2.document.location.href
}
//-->
</script>


</body>
</html>


how can I have the source code of a external site? anyone could post a solution? can be in Java, or other language

thanks for reading

best regards

Last edited by mikedikta; Oct 11th, 2007 at 01:50. Reason: add code tag
Reply With Quote

  #2 (permalink)  
Old Oct 11th, 2007, 05:22
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: getting source code of a page

Hmmmm frames

You could try this

Code: Select all
//this is frame1.htm
<html>
<title>Frist Frame</title>
<body>

<form name="view">
<input type="button" name="source" onclick="vs()" value="View This Page's Source">
</form>
<script language="Javascript">
<!--
var frameSource
function vs() {
frameSource = top.frame2.document.getElementsByTagName('html')[0].innerHTML;
}
//-->
</script>
Now you should have all the code between the html tags stored in frameSource variable.

</body>
</html>
[/code]
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Reply With Quote
  #3 (permalink)  
Old Oct 14th, 2007, 18:39
New Member
Join Date: Oct 2007
Location: US
Age: 38
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: getting source code of a page

thanks, but it doesn't work, permission denied in getting HTMLDocument.getElementsByTagName

as I said, the page I want the source is external (like yahoo.com)
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Programming Source Code Library Monie Webforumz Cafe 11 Mar 10th, 2008 04:09
Can somebody give me the code to hide the source code? renren JavaScript Forum 7 Mar 7th, 2006 12:27
Source Code Clean-up Wizard jswebdev PHP Forum 3 Feb 7th, 2006 00:56
Viewing source code?? autumn_whispers2me Web Page Design 4 Feb 14th, 2005 17:40
need help-source code ayus_82 ASP.NET Forum 1 Sep 20th, 2004 07:48


All times are GMT. The time now is 05:39.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43