How avoid loading iframe & overlay

Hi,

I am using Control modal to open the iframe by using HREF tag in the AREA Tag. In my application, There are some cases in which i may have the HREF value as the character "#". Actually I can not avoid having href='#' in some tags as it gets automatically generated.

I do not want to open the iframe and the overlay window for the onclick event on the area tag those having HREF='#'. How can i avoid opening of Iframe and overlay if HREF='#'. Can anybody please suggest what changes i need to do and where in the control.modal.js

Thanks, Pravin

Posted April 22nd, 2007 at 1:20pm by Pravin

i think you can test the content of the id

if it s equals to "#" you do nothing else you open your modal

no ?

Posted April 23rd, 2007 at 6:31am by Nico

you mean you don't want them to follow link?

Event.observe(window, 'load', function(){ m = new Control.Modal(false); $('link').observe('click', function(e){ m.open(); Event.stop(e); }) })

... some link

or if you want to skip those with href="#" try this:

$A(document.getElementsByTagName('area')).each(function(area){ area.href != "#" ? new Control.Modal(area) : area.observe('click', function(e){ Event.stop(e); }); })

Posted April 23rd, 2007 at 7:17am by kangax

Thank u nico & Kangax for ur reply.

Actually I want to skip those with href="#".

Kangax, U have given the piece of code. I am using @version 1.1.4 of control.modal. As i am newbie, I would like to know if i need to replace some part of code in control.modal.js file with the code which u gave or should i add somewhere in the control.modal file.

$A(document.getElementsByTagName('area')).each(function(area){ area.href != "#" ? new Control.Modal(area) : area.observe('click', function(e){ Event.stop(e); }); })

Thanks, Pravin

Posted April 23rd, 2007 at 2:46pm by Pravin

Pravin,

Don't change anything in Control.Modal.js

What you should do is simply put this code into tag (right after including Control.Modal.js) like this

Event.observe(window, 'load', function(){ $A(document.getElementsByTagName('area')).each(function(area){ area.href != "#" ? new Control.Modal(area) : area.observe('click', function(e){ Event.stop(e); }); }) })

Posted April 23rd, 2007 at 3:51pm by kangax

Thanks for your reply again. But Unfortunately, It does not work for me. I just included ur coded in the head section like this... #modal_container { padding:5px; background-color:#fff; border:1px solid #666; overflow:auto; font-family:"Lucida Grande",Verdana; font-size:12px; color:#333; text-align:left; }

#modal_container.test {
    background-color:#900;
    color:#fff;
    padding:30px;
    text-align:center
}
#modal_overlay {
    background-color:#000;
    height:500%;
}
#modal_overlay.test {
    background-color:#fff;
}

Event.observe(window, 'load', function(){ $A(document.getElementsByTagName('area')).each(function(area){ area.href != "#" ? new Control.Modal(area) : area.observe('click', function(e){ Event.stop(e); }); }) })

The page rendered in the browser has the body section like this...

Event.observe(window,'load',function(){new Control.Modal($('C65'),{iframe: true, width:500, height:350});new Control.Modal($('C66'),{iframe: true, width:500, height:350});new Control.Modal($('C67'),{iframe: true, width:500, height:350});});

Still When i click on the area having id='C67' which has the attribute hred='#', The overlay and popup appears. Also When i click on the other two areas whose href value is assigned with the url, the iframe opens but not with the specified width & height. Instead it opens a small iframe of width 20px and height 20px with scrollbar.

Why is it happening, what could be the error.

Thanks, Pravin

Posted April 24th, 2007 at 1:36am by Pravin

i don t know if it works

but try to place the script that kangax gives you after the link generation

if you see the doc it says :

Modal One Modal Two $$('a.modal').each(function(link){ new Control.Modal(link); });

so the script is not in the zone but after the links

:D

Posted April 24th, 2007 at 5:28am by Nico

Pravin,

I really don't know why this doesn't work. I'm gonna have to take a look at the actual code to tell what the problem is.

P.S. It is possible though that and implementation of events is quirky or not consistent across browsers. I never had a chance to work with those so can't give an answer on the fly.

Posted April 24th, 2007 at 8:39am by kangax

Login or Register to Post