开发者

How to open a link from a Joomla article into the same article window

I'm trying to have the users click on the links in an article, but have the results open in the same article (so the article reloads and open the target page in itself, like it would if it was in an iframe, right now it reloads the whole page), I do not want to use the main menu, and would also like to avoid using iframes, normally if this was HTML I'd use ajax or something similar, but in jooml开发者_Go百科a i'm not sure, any suggestions?


If you have HTML ids you are better of using AJAX, Joomla has jquery and mootols to make your life easier. There are couple of things you should know

  1. Look into JUMI, it will allow you to use PHP within your articles. Can be very helpful. You can use it to add javascript framework from article for your ajax like so <?php JHTML::_('behavior.mootools'); ?>

  2. You want to be careful while editing the article, if you use editor it will strip out your JavaScript from the article. You are better of just using "No-Editor" or if you are using JCE switch to text by pressing "Show/Hide" just above the editor in the left corner.

  3. Add events to your IDs in domready instead of inline js. Something like this

/* MooTools Example */
window.addEvent('domready', function(){
    $('link-1').addEvent('click', function(){ new Ajax(...).request(); });
    $('link-2').addEvent('click', function(){ new Ajax(...).request(); });
    $('link-3').addEvent('click', function(){ new Ajax(...).request(); });
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜