Detect when clicking a link, open in a new frame

I would like to create a basic URL rework using frames.

I do not have access to .htaccessexecute mod_rewrite.

Is there a way to use PHP, jQuery, JavaScript, etc. to determine which URL was clicked and then open the URL in a new frame?

Ex: the user clicks on /index.php?12345, he will open in the frame /pages/12345/index.html, and if they click on /index.php?54321, the URL will open in the frame/pages/54321/index.html

0
source share
5 answers

, , . URL :
http://example.com/content/example
http://example.com/index.php?cat=content&page=example

, http://example.com/index.php/content/example, - - index.php, index.php( )

$_SERVER['PATH_INFO']

, , .

PHP.net $_SERVER ['PATH_INFO']

, scriptfilename, , . , script URL- http://www.example.com/php/path_info.php/some/stuff?foo=bar, $_SERVER ['PATH_INFO'] /some/stuff.

+1

PHP- :

if (!empty($_REQUEST)) {
    $page = array_pop($_REQUEST);
    if (is_numeric($page)) {
        header("Location: pages/$page/index.html");
        exit;
    }
}
+1

, , , .

, JQuery, PHP AJAX. PHP , ( include()) JQuery JSON.

0
source

Such jquery may help,

jQuery(function($){
  //this prevents all link elments' default behaviour 
  //when you click they won't navigate the page
  $("a").click(function(){
    //you get the links href
    var actual_url = $(this).attr("href");
    var new_url = "";
    //[write your code here for converting actual url to new one]
    //and open the new url in the frame you want
    window.parent.yourFrameName.location = new_url;
    //necessary for preventing default behaviour
    return false;
  });
});

Sinan.

0
source

The best solution is to use jquery to check if the link has been visited, and then change the target link to _blank.

You can use the plugin from this site: link text , and then execute this code:

 $('a').visited(function () {
  $(this).attr('target','_blank');
});

I think this is what you are looking for.

0
source

All Articles