Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to open links in "_parent" target instead of "_blank" for easier iframe integration #323

Closed
nouser2013 opened this issue May 2, 2016 · 20 comments

Comments

@nouser2013
Copy link

Dear dev's,

for easier iFrame integration I'd like to be able to set the target property of outgoing URLs. On my webpage, I currently have an interactive map with several areas. Upon clicking, a link such as www.mydomain.com/deep-link#area_1 is opened; the browser scrolls down to the respective anchor.

Unfortunately, it always opens in a new window. I'd like to open in "_parent" to hint to the browser to simply scroll instead of loading the whole page again, even over cross-origin.

Thanks.

@nouser2013 nouser2013 changed the title Option to open links in "_parent" target instead of "_black" for easier iframe integration Option to open links in "_parent" target instead of "_blank" for easier iframe integration May 2, 2016
@yohanboniface
Copy link
Member

Would allow anchor values only in the link be an option? In other words:

  • if the link starts with http:// => open in a new window
  • if the link starts with '#' => open in the same window

It would be a bit implicit, but we already have a bunch of options in uMap, and I'm not sure this needs a new one.

@yohanboniface
Copy link
Member

Of maybe link domain == current domain => same window?

@nouser2013
Copy link
Author

Would allow anchor values only in the link be an option? In other words: [...]

Well, functionality-wise, yes, of course. You could also directly parse the target="" value from the textbox like so:

  • _parent:http(s)://...
  • _blank:http(s)://
  • _self:http(s)://

Or maybe link domain == current domain => same window?

Nope, due to x-origin restriction you have no way of determining where the map is viewed: you cannot say if it's stand-alone in a separate tab/window or within an iframe on a parent page. Your condition would likely never match since you probably don't want to link to uMap in most cases.

@yohanboniface
Copy link
Member

Nope, due to x-origin restriction you have no way of determining where the map is viewed

Good point!

You could also directly parse the target="" value from the textbox

I'll think about that option.

@nouser2013
Copy link
Author

Alright, thanks. I'd be very nice to have it, here's the (German) web page I'd like to use it in: http://www.pro-fuerstenried.de/2016/05/oekologie-im-viertel-ein-gastbeitrag/

Click on a green area on the map and jump down to the appropriate detailed description...

@tourenfex
Copy link

Is there an solution for this problem?

@nouser2013
Copy link
Author

@yohanboniface with regard to your other comment in #349 (bottom):

There is not way to change that behaviour for now sadly. I've looked at it, and it's not that easy given the action is made in javascript (it's not a real HTML link), and thus there are restriction for an iframe to communicate with parent.

As I don't know how exactly the links are created or what happens when you click on the overlay elements, here are the two ways that seem to work according to community:

Redirect iFrame parent by clicking anchor link inside:

http://stackoverflow.com/questions/1037839/how-to-force-link-from-iframe-to-be-opened-in-the-parent-window

  1. add <base target="_parent" /> to top of the page within the iFrame; this changes all links within the iframe to load in the parent window, or
  2. add target="_parent" to a single anchor tag. This changes just the respective link.

Redirect iFrame parent by javascript call:

http://stackoverflow.com/questions/580669/redirect-parent-window-from-an-iframe-action

  1. exchange the window.location = ...-call with window.top.location.href = .... This will load the URL in the iFrame's parent window. No restriction.

Determine when to load content in parent window

Well, see #323 (comment) for the suggestions already given...

@yohanboniface
Copy link
Member

exchange the window.location = ...-call with window.top.location.href = .... This will load the URL in the iFrame's parent window. No restriction.

Is http://jsfiddle.net/ppkzS/ working for you?

@yohanboniface
Copy link
Member

It's actually working if I try it in uMap:

http://umap.openstreetmap.fr/en/map/demo_1#12/53.2397/9.0308

I'll investigate a bit more and have a try. Need to find the right format syntax though.

@tourenfex
Copy link

Yes, this would solve my problem!

This is my map: http://umap.openstreetmap.fr/de/map/webcams_98826#10/46.8405/12.6755

The links should open in the same (_parent) window.


Von: Yohan Boniface notifications@github.com
Gesendet: Samstag, 20. August 2016 09:09
An: umap-project/umap
Cc: tourenfex; Comment
Betreff: Re: [umap-project/umap] Option to open links in "_parent" target instead of "_blank" for easier iframe integration (#323)

It's actually working if I try it in uMap:

http://umap.openstreetmap.fr/en/map/demo_1#12/53.2397/9.0308

I'll investigate a bit more and have a try. Need to find the right format syntax though.

You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://github.com//issues/323#issuecomment-241184321, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AUJv4RxvptsJ4KNTligbJB2DX1pOI9Y-ks5qhqgigaJpZM4IVHRV.

@yohanboniface
Copy link
Member

Will be in next release only.
Looks like this:
screenshot from 2016-08-20 11-12-35

@tourenfex
Copy link

Perfect! Thank you for your great job! When will be the next release approximately?

@nouser2013
Copy link
Author

Thanks. Looks perfect. Can't wait to try it out...

@tourenfex
Copy link

hey guys, when will be the next release? i would need this option as soon as possible.

@ne0guille
Copy link

any news on this?

@tourenfex
Copy link

the above option is still missing in the new release. what is the reason?

@yohanboniface
Copy link
Member

yohanboniface commented Oct 2, 2016

the above option is still missing in the new release.

You meant "I can find this option in the new version, am I not looking at the right place?".
So when you edit a polygon (only polygons have outlink), you should have both the outlink property and the way to define how the link should behave.

@tourenfex
Copy link

Is it possible to get this option for markers too?

Thank you for your help!

Von: Yohan Boniface [mailto:notifications@github.com]
Gesendet: Sonntag, 2. Oktober 2016 22:02
An: umap-project/umap
Cc: tourenfex; Comment
Betreff: Re: [umap-project/umap] Option to open links in "_parent" target instead of "_blank" for easier iframe integration (#323)

the above option is still missing in the new release.

You meant "I can thing this option in the new version, am I not looking at the right place?".
So when you edit a polygon (only polygons have outlink), you should have both the outlink property and the way to define how the link should behave.


You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://github.com//issues/323#issuecomment-250992112, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AUJv4YvQfgoLLmQtF6mFJphHx846M3Xvks5qwA25gaJpZM4IVHRV.

@tourenfex
Copy link

Will this option be implemented for markers too in one of the next updates?

@servizislovenia
Copy link

hello, any news for this release? thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants