N
N
Nicomashi2011-02-04 11:14:46
JavaScript
Nicomashi, 2011-02-04 11:14:46

Opening Ajax windows with a script?

Hello!

There is a client site-one-page on Joomla! The problem with it is that all additional materials (pages) open in Ajax windows, and when you go to these opening pages from search engines, they are shown in a simplified template. Now there is a task so that when entering such a page, the user is redirected to the main page and this material is opened to him in the Ajax window. The windowing mechanism is implemented through the RokBox plugin ( demo ).

Links look like:

&lt;a href=&quot;/extensions/images/stories/demo/rokbox/rs8.jpg&quot;<br/>
rel=&quot;rokbox[561 350]&quot;<br/>
title=&quot;Audi RS8 :: Sample Caption for RS8&quot;&gt;<br/>

The whole head has already broken how to do it. I'd be grateful for any pointers to useful information.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
homm, 2011-02-04
@homm

On the main page, go through all such links and add some parameter to them:

$(function() {
  $('a[rel^="rokbox"]').each(function(){
    if (this.href.indexOf('?') == -1) {
      this.href = this.href + '?ajax=1';
    } else {
      this.href = this.href + '&ajax=1';
    }
  });
});

On the server, check if there is no ajax parameter, then the page was loaded via a direct link and a redirect is needed.

A
alexpogodin, 2011-02-04
@alexpogodin

Try checking the X-Requested-With header so you don't have to add a parameter to the URL. I think all JS libraries now add it (standard?)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question