473,683 Members | 3,524 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

view-source:'+docume nt.location'

This will give me the source of the current page.

<a herf="javascrip t:document.loca tion = 'view-source:'+docume nt.location">te stpage.htm</a>

I want to display the source of another page, using something like this but it doesn't work:

<a herf="javascrip t:document.loca tion = 'view-source:'+'testp age.htm'>testpa ge.htm</a>

?? Won't work, unless it is saved on a server with http:// in front of it.

Jul 20 '05 #1
5 12582


John Taylor-Johnston wrote:
This will give me the source of the current page.

<a herf="javascrip t:document.loca tion = 'view-source:'+docume nt.location">te stpage.htm</a>

I want to display the source of another page, using something like this but it doesn't work:

<a herf="javascrip t:document.loca tion = 'view-source:'+'testp age.htm'>testpa ge.htm</a>

?? Won't work, unless it is saved on a server with http:// in front of it.


Try
<a href="testpage. htm"
onclick="locati on.href = 'view-source:' + this.href;
return false">

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2

"John Taylor-Johnston" <ta******@colle gesherbrooke.qc .ca> schreef in bericht
news:3F******** *******@college sherbrooke.qc.c a...

I want to display the source of another page, using something like this but it doesn't work:
<a herf="javascrip t:document.loca tion = 'view-source:'+'testp age.htm'>testpa ge.htm</a>
?? Won't work, unless it is saved on a server with http:// in front of it.


True, you will have to prepend a protocol. When you are not testing on a
webserver, you should use the file:// protocol.

Regarding the usage of the javascript: pseudo-protocol, you should read:
http://jibbering.com/faq/#FAQ4_24
JW

Jul 20 '05 #3
MartinTry
<a href="testpage. htm"
onclick="locati on.href = 'view-source:' + this.href;
return false">


Thanks. Great. Just for fun, ii wanted to put in all inside the href=""

<a href="javascrip t:onclick="loca tion.href = 'view-source:' + this.href; return false"">click</a>

I have too many quotes. How can I work around this?

Still learning ...

Jul 20 '05 #4
John Taylor-Johnston <ta******@colle gesherbrooke.qc .ca> writes:
Thanks. Great. Just for fun, ii wanted to put in all inside the href=""

<a href="javascrip t:onclick="loca tion.href = 'view-source:' + this.href; return false"">click</a>
That won't work. The script uses "this.href" which referst to the
actual href of the link. If you put the script itself into the href, then
it won't have the URL it needs.
I have too many quotes. How can I work around this?
To fix the quotes, use something like:

<a href="javascrip t:onclick='loca tion.href = \'view-source:\' + this.href;
return false'">click</a>

As I said, it won't work. You generally shouldn't use the javascript:
pseudo protocol. You definitly shouldn't return false from it, it isn't
an event handler.
Still learning ...


Unlearn "javascript :" for responding to clicks, it will be better for
you in the long run.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #5
Janwillem Borleffs wrote:
Regarding the usage of the javascript: pseudo-protocol, you should read:
http://jibbering.com/faq/#FAQ4_24


I still don't understand why people are continuously calling `javascript:'
a "pseudo protocol". It is part of an URI, and RFC 2396 does not state that
an URI must address a specific protocol. The part before the `:' identifies
an URI scheme, so `javascript:' is simply a not-standardized URI scheme.
PointedEars

Jul 20 '05 #6

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

Similar topics

3
6798
by: NiQuil | last post by:
Hello people, I am creating a portal which should be easy maintainable by non-programmers. Thus far people can easyly change the text, set it Bold Italic and Underlined. Also i can set a footnote which will be displayed at the bottom of the text. The next feature i would like to create involves creating a link. --->I want to be able to insert a link in a piece of tekst.<---
1
1473
by: Rick | last post by:
How would you create a different alt view for each image in the following? <script language="JavaScript"> var i = 1; banner1= new Image(); banner1.src = "image1jpg"; banner2= new Image(); banner2.src = "image2.jpg";
2
1830
by: relaxedrob | last post by:
Hi All! I have a frameset document and I want each mainFrame document to have the following ability: - be viewed by itself (i.e. without frames if within frameset). - be viewed within frame (i.e. put back in the frameset if not within frameset). I have written the following so far:
9
36722
by: alu | last post by:
Could someone explain the discrepancies within and between the stated definitions / usage of 'document.location' , 'document.URL' vs. their actual functionality? Should they be read-only when in fact they are not? Is 'document.URL' also deprecated, and should therefore never be used? What is the last word re: the proper syntax for returning and setting the current window's location? We have: document.location document.location.href
10
2695
by: Geoff | last post by:
I am using the following statement in a script: If (res == 123) document.write (" Blah Blah"); else document.write (" XYZ"); This of course brings up a new page on my site and prints Blah Blah. However, the colour of the page is white & I want it to match the colour of the html page from which the original request was sent. I have tried playing with
5
2958
by: WilliamRLinden | last post by:
Hi world! we are pretty new to JavaScript and have been struggling for now 2 days on this problem ... We would appreciate mercy if anyone can give us some. Basically we are trying to simulate the tab key when the down arrow key is pressed. (we know there are other way to control focus flow but we use a lot of dynamic jsp fields, that will make the flow control a nightmare, we just want basic tabbing from the arrow key)
1
1420
by: h3ctor83 | last post by:
hello everyone.. can anybody help me? i made an application to upload files to the server.. and after that use ris able to download that file again.. but after downloading the file (specifically word document), i found that the content is not correct.. lets say the original content is "This is a word document"..after downloading the file..the content becomes "&@%&*@**)@!)(!@)((___@!#" (some invalid unreadable characters).. what cause...
1
2889
by: =?Utf-8?B?UmljaA==?= | last post by:
I placed a button on a form menustrip for the purpose of causing the horizontal scrollbar of my form to appear so that I can access controls outside of the form's current view (the controls are further to the right of the form than the form's default width - which may take up the entire screen for some users). The form contains panels which will contain either textboxes or datagridviews. The button is located on the menustrip towards...
4
3454
by: dasnowball | last post by:
Hi everyone, I'm developing an application using ASP.NET with VB, connected to a SQL Server, running on .NET 2 framework. I am developing a training system where documents are uploaded into the system and a test is defined. The problem I am having is when users need to view these documents. Currently, they select which item they wish to complete training on, and by clicking the start test button, it pulls the location of this document...
4
3812
by: roadiee | last post by:
I am sure this must be common but I can't seem to find how to do it. I have a file structure as follows: php - getimages.php gallery - index.html - image1.jpg - image2.jpg - image3.jpg
0
8504
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
9043
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
8922
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8771
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
6429
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
4299
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
4519
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2934
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
3
1921
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.