Adding a link to a page?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I know it looks simple --- bear with me.

There have been a few commercial applications which have the ability
to add a link directly into a page  --

I do not mean in an editor  --  I mean you click on the page for a
menu and one option that pops up is insert hyperlink.    You add some
data to the form ( its about the same that Kompozer would ask for )
and you click ok,  and the form vanishes.   The link you want appears
in a few moments on the webpage.

I have considered  doing this by using a simple form to gather user
input,  followed by a cgi based script to edit the page source, update
it and then refresh the page from the source file.  I think this is a
workable idea,  but it sounds heavy handed.

So I was wondering --- Is there a better way to do this?  The other
stuff says its HTML  but I was wondering if some other way was

Pardon the new guy.

Re: Adding a link to a page?

Dan wrote:

Quoted text here. Click to load it

You mean an (X)HTML document.
Quoted text here. Click to load it

Probably you mean Netscape/Mozilla _Composer_, or its fork, KompoZer.

Quoted text here. Click to load it

Probably because a server-side script takes the form data and generates a
new document.
Quoted text here. Click to load it

You may use any server-side technology, including CGI.  However, CGI is
apparently going out of fashion; major Web hosters are deprecating it in
favor of server module-based approaches (like PHP as Apache module
instead of PHP as CGI program).

There is also the possibility to do this client-side (with the DOM), but for
the changes to persist usually you also need to do it server-side (i.e., you
would use XHR to send the information to the server ─ to avoid a change of
context ─, and DOM to add it to the document in the same step).

Quoted text here. Click to load it

Usually there is no (*hyper*)link without the (eXtensible) *Hyper*Text
Markup Language.

Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.

Re: Adding a link to a page?

On Tue, 8 Feb 2011 10:34:14 -0800 (PST), Dan wrote:

Quoted text here. Click to load it

This is most commonly done with server side languages such as PHP.
That is, work is being done behind the scenes that you will not see until
the output is printed. The output at your browser is in HTML because that
is what was happening.

If something vanishes before your eyes while the page remains intact, that
is most likely being done with a scripting language within the browser. In
a browser such as firefox, you could turn off the javascript, click to
change the output to eliminate any styling, and you will see the bare nuts
and bolts, including that part that vanished.

Re: Adding a link to a page?

Quoted text here. Click to load it

Thanks for the replies folks.

I think its in the browser entirely,  as there is no network
connection to this at all, however,  it works as indicated.

What happens  is that you add a link,  you get the link in the
page.    The link will not work until you get a full connection.  If
you add a link to something you
can open  then,  it will work.

Once you are hooked up to the net, the link works as expected.

My own take ( forgive a day dreaming idiot ) was to use a perlscript
to do the editing of the pagesource.  This confirmed,  a tcl/tk or
html form solution would collect the info from the user for
the edit of the page source.  That in place and ok,  we would need to
add some means of having the browser look twice at the file,   so it
will use the page source to refresh the image.

If I can get all that to work,   then I think I have a way thru to the
solution I want.

Re: Adding a link to a page?

Dan wrote:

Quoted text here. Click to load it


There is no "javascript".  And the name is _Firefox_.

Quoted text here. Click to load it

Not necessarily, the element could as well have been removed from the
document tree.

Recommendation: Take everything "richard" says with a handful of salt.

Quoted text here. Click to load it

They could be using a local webserver, or they could be storing the
information in cookies, localStorage or sessionStorage and/or simply adding
the link to the client-side document (temporarily), like so:

    <script type="text/javascript">
      function addLink(form)
        if (!navigator.onLine)
          var link = document.createElement("a");
          link.href = form.elements["url"].value;
          return false;

        return true;
    <form action="foo" onsubmit="return addLink(this)">
          <th><label for="url"><u>U</u>RL:</label></th>
          <td><input type="url" name="url" id="url" accesskey="u"></td>
          <th><label for="linktext"><u>T</u>ext:</label></th>
          <td><input name="linktext" id="linktext" accesskey="t"></td>
      <div><input type="submit" value="Add Link"></div>
But this would be a topic for another newsgroup, comp.lang.javascript.

Quoted text here. Click to load it


Parse error.

Without a webserver, it is unlikely (although not entirely impossible) that
you can run a Perl script initiated by a user action in a webclient.

Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
  -- from < (404-comp.)

Site Timeline