[EP-tech] Re: Script to open a.ep_document_link in pop-up
Jacob Wenzel
jw at energiakademiet.dk
Wed Aug 13 12:41:03 BST 2014
Ups, sorry John, never mind :)
I just needed:
document.observe("dom:loaded", function() {
links = $$("a.ep_document_link");
links.each(function(link){
link.observe("click", function(event){
window.open(link.href,'','height=575,width=720');
event.stop();
});
});
});
Thanks, it is perfect now!
/Jacob.
On 13-08-2014 13:32, Jacob Wenzel wrote:
> Thanks a lot John, both do work!
>
> Unfortunately they open a new tab and not a pop up, which can be
> confusing for less tech-savvy users.
>
> Do you know, how I can pass attributes to the new window, so I can
> specify height and width to the new window and perhaps remove the menu
> bars?
>
> Preferably I would like my pop-ups to look like the one seen on the
> embedded eprint at the bottom of the linked post below, but any
> solution where the user sees the new window popping up on top of the
> main site instead of switching tabs would be acceptable.
> http://energiakademiet.dk/en/eve-fisher-lovmaessige-begraensninger-for-borgerstyret-energi/
>
> Thanks again in advance! And I am sorry if this is basic stuff, I am
> not very good with javascript in general, but I really appreciate your
> help.
>
> /Jacob
>
> On 12-08-2014 13:59, John Salter wrote:
>>
>> Hi Jacob,
>>
>> From the snippet of Prototype below, it looks like you’re defining a
>> function ‘new_window_links’, but never actually calling it?
>>
>> Does this work (anonymous function):
>>
>> document.observe("dom:loaded", function() {
>>
>> links = $$("a.ep_document_link");
>>
>> links.each(function(link){
>>
>> link.observe("click", function(event){
>>
>> window.open(link.href);
>>
>> event.stop();
>>
>> });
>>
>> });
>>
>> });
>>
>> or this (same named function, specifically called):
>>
>> document.observe("dom:loaded", function() {
>>
>> function new_window_links(){
>>
>> links = $$("a.ep_document_link");
>>
>> links.each(function(link){
>>
>> link.observe("click", function(event){
>>
>> window.open(link.href);
>>
>> event.stop();
>>
>> });
>>
>> });
>>
>> }
>>
>> new_window_links();
>>
>> });
>>
>> I haven’t tested either!
>>
>> Cheers,
>>
>> John
>>
>> *From:*eprints-tech-bounces at ecs.soton.ac.uk
>> [mailto:eprints-tech-bounces at ecs.soton.ac.uk] *On Behalf Of *Jacob Wenzel
>> *Sent:* 12 August 2014 12:35
>> *To:* 'eprints-tech at ecs.soton.ac.uk'
>> *Subject:* [EP-tech] Script to open a.ep_document_link in pop-up
>>
>> Hi guys!
>>
>> Im trying to open document links - '<a class="ep_ducument_link"
>> href="...' - in a pop up window (not a new tab), but I can't figure
>> out how to do this in prototype.
>>
>> In jquery i do this:
>>
>> jQuery(document).ready(function($) {
>> jQuery('a.ei_popup').live('click', function(){
>> newwindow=window.open($(this).attr('href'),'','height=575,width=720');
>> if (window.focus) {newwindow.focus()}
>> return false;
>> });
>> });
>>
>> which does the trick.
>>
>> I am totally new to prototype, but I found this snippet, that is
>> supposed to do the same:
>>
>> document.observe("dom:loaded", function() {
>> function new_window_links(){
>> links = $$("a.ep_document_link");
>> links.each(function(link){
>> link.observe("click", function(event){
>> window.open(link.href);
>> event.stop();
>> });
>> });
>> }
>> });
>>
>> But it doesn't do anything. I checked the source code, and the code
>> does load fine from 90_local.js.
>>
>> Thanks in advance, help and pointers will be greatly appreciated.
>>
>> Have a nice day!
>>
>> --
>>
>> *Med venlig hilsen/Best regards*
>>
>> *JACOB WENZEL**
>> *Projektleder**
>>
>> *ENERGIAKADEMIET*
>> Strandengen 1
>> 8305 SAMSØ
>> +45 60 61 15 97
>> jw at energiakademiet.dk <mailto:jw at energiakademiet.dk>
>> www.energiakademiet.dk <http://energiakademiet.dk>
>>
>>
>>
>> *** Options:http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
>> *** Archive:http://www.eprints.org/tech.php/
>> *** EPrints community wiki:http://wiki.eprints.org/
>> *** EPrints developers Forum:http://forum.eprints.org/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ecs.soton.ac.uk/pipermail/eprints-tech/attachments/20140813/04a29e20/attachment-0001.html
More information about the Eprints-tech
mailing list