Jump to content

Link changing on the fly


markstephenson

Recommended Posts

Im sure this will be a php/mysql/javascript answer, but i think the clever stuff will have to be done in Javascript...

What I am wanting to do is have 2 frames, one containing some navigation stuff, one containing the main site displayed.  What i am looking to do is automatically check the page which is loaded (read the html) and allow me to use the right click (custom context menu?) on hrefs and images within hfrefs to send their value to a database.

Is this even possible?  is there a better way of doing it?

Many thanks
Link to comment
Share on other sites

There are a lot of things that you need to look into separately, but nothing you have asked for seems impossible:


[quote]Im sure this will be a php/mysql/javascript answer, but i think the clever stuff will have to be done in Javascript...[/quote]
    Yeah, if the side frame is never to refresh, but remain aware of it's changing surroundings, then javasctipt is the answer.

[quote]What I am wanting to do is have 2 frames, one containing some navigation stuff, one containing the main site displayed.  [/quote]
    [i]meh[/i], I don't like that you're using frames, but it should work. The reason why I say so is that you'll need some ajax anyway for your context menu, so why not refetch the whole display frame?

    [quote]What i am looking to do is automatically check the page which is loaded (read the html) and allow me to use the right click (custom context menu?) on hrefs and images within hfrefs to send their value to a database.[/quote]

    Sending values without refreshing will need some ajax. This expects some sort of return (which is the new context menu?), or a brand new display frame.  You can set events to fire on right-click , but mac users might hate you.

  To have the left-frame aware of what's going on, research setAttribute() & getAttribute(), or use a dummy input to store the filename clicked:
[code]
<script>
function addToBucket(url)
{
      document.getElementById('bucket').value=url;
      // or whatever.setAttribute('active')=url;

      //now do things according to plan   
      processChanges();
}

function fetchFromBucket()
{
    return document.getElementById('bucket').value;
      // or whatever.getAttribute('active');
}

function processChanges()
{
    var activeUrl = fetchFromBucket();
    /**
    // do whatever you need to based on this condition
    **/
}
</script>

<input type="hidden" id="bucket">

<a href="file1.php" onclick="addToBucket(this.href);">
<a href="file2.php" onclick="addToBucket(this.href);">
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.