Hi all first time im posting here, hope what i've written is clear.

I'm trying to make a popup work using event.observe for all anchor
tags with the CSS selector 'popup'.

in the HTML i have this:

< a href="somelink.php" class="popup">Click to go someplace </a>

in my javascript I have a:

Event.observe(window, 'load', function (){

});

wrapper with code inside the event.observe code inside


1. heres the 1st method I tried:

$$('a.popout').each( function(thePopout) {      Event.observe( thePopout,
'click',  popout);  }  );

function popout()
{
        window.open(this.href, this.innerHTML, 'width=500,height=500');
        return false;
}

-----------------------
In IE i get a popup window with a 404 error. Seems like the 'this'
reference isnt having the right effect

In Firefox I get the correct popup window however the original page
also changes to the href location.  Seems like return false; isnt
having the desired effect.
-------------------

2. the second method I tried

$$('a.popout').each( function(thePopout) {      Event.observe( thePopout,
'click',  popout);  }  );


function popout(event)
{
        var element = Event.element(event);
        window.open(element.href, element.innerHTML,
'toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=yes,copyhistory=no,width=500,height=500');
        return false;
}

------------------------------------
In IE everything works great!!
In Firefox I still get the same problem as before, it appears as if
the return false; at the end of the function is not working to tell
firefox not to follow the link
-----------------------------------

I have also tried using an anomyomous function within Event.observe
and just to ease my brain, i tried this:

$$('a.popout').each( function(s) {      Event.observe( s, 'click',
popout.bindAsEventListener(s)  ) } );

which shouldnt be any different to a standard event.observe, and
isn't!

thanks for reading, any insights would be much appreciated.

The reason im doing it this way and not in the html :
< a href="somelink.php" class="popup" onclick="popup(); return
false;">Click to go someplace </a>

is to keep the html and javascript separate and to make changing
normal links to popups really easy in the future (and to style the
popups differently to normal links)


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to