view-source:'+document.location'

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Taylor-Johnston

    view-source:'+document.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.

  • Martin Honnen

    #2
    Re: view-source:'+docume nt.location'



    John Taylor-Johnston wrote:
    [color=blue]
    > 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.[/color]

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

    --

    Martin Honnen


    Comment

    • Janwillem Borleffs

      #3
      Re: view-source:'+docume nt.location'


      "John Taylor-Johnston" <taylorjo@colle gesherbrooke.qc .ca> schreef in bericht
      news:3F90B0D1.5 83AFB28@college sherbrooke.qc.c a...[color=blue]
      >
      > I want to display the source of another page, using something like this[/color]
      but it doesn't work:[color=blue]
      >
      > <a herf="javascrip t:document.loca tion =[/color]
      'view-source:'+'testp age.htm'>testpa ge.htm</a>[color=blue]
      >
      > ?? Won't work, unless it is saved on a server with http:// in front of it.
      >[/color]

      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:



      JW



      Comment

      • John Taylor-Johnston

        #4
        Re: view-source:'+docume nt.location'

        MartinTry
        [color=blue]
        > <a href="testpage. htm"
        > onclick="locati on.href = 'view-source:' + this.href;
        > return false">[/color]

        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 ...

        Comment

        • Lasse Reichstein Nielsen

          #5
          Re: view-source:'+docume nt.location'

          John Taylor-Johnston <taylorjo@colle gesherbrooke.qc .ca> writes:
          [color=blue]
          > 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>[/color]

          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.
          [color=blue]
          > I have too many quotes. How can I work around this?[/color]

          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.
          [color=blue]
          > Still learning ...[/color]

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

          /L
          --
          Lasse Reichstein Nielsen - lrn@hotpop.com
          Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
          'Faith without judgement merely degrades the spirit divine.'

          Comment

          • Thomas 'PointedEars' Lahn

            #6
            Re: view-source:'+docume nt.location'

            Janwillem Borleffs wrote:
            [color=blue]
            > Regarding the usage of the javascript: pseudo-protocol, you should read:
            > http://jibbering.com/faq/#FAQ4_24[/color]

            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

            Comment

            Working...