-
AuthorPosts
-
activha Friend
activha
- Join date:
- July 2012
- Posts:
- 114
- Downloads:
- 17
- Uploads:
- 6
- Thanks:
- 5
- Thanked:
- 1 times in 1 posts
July 30, 2012 at 9:48 pm #179519There is a bug when trying to open a link with tmpl=component using the script in the component.php
if(window.parent == window) {
window.top.location.href = window.location.href.replace(/(&*)tmpl=component/ , ‘&’);
}When using for instance links for editing K2 items, the page opens in a loop with constant redirection due to this script.
How can I correct it to avoid this behavior while keeping the use of the script in mobile devices (opening the pop up in new window ) ?
Thanks for helping
Thanh Nguyen Viet FriendThanh Nguyen Viet
- Join date:
- September 2014
- Posts:
- 1461
- Downloads:
- 0
- Uploads:
- 44
- Thanked:
- 258 times in 217 posts
July 31, 2012 at 4:44 am #462661Hello activha,
Please try to replace this code snippet:
if(window.parent == window) {
window.top.location.href = window.location.href.replace(/(&*)tmpl=component/ , '&');
}With this one:
if(window.top!=window.self) {
window.top.location.href = window.location.href.replace(/(&*)tmpl=component/ , '&');
}activha Friendactivha
- Join date:
- July 2012
- Posts:
- 114
- Downloads:
- 17
- Uploads:
- 6
- Thanks:
- 5
- Thanked:
- 1 times in 1 posts
July 31, 2012 at 8:09 am #462685Thanks, this avoids looping through the window but the side effect is that the pop up opens and then directly opens its content in a new window with tmpl=component.
What I would like to achieve is this but without the side effect 🙂
Thanh Nguyen Viet FriendThanh Nguyen Viet
- Join date:
- September 2014
- Posts:
- 1461
- Downloads:
- 0
- Uploads:
- 44
- Thanked:
- 258 times in 217 posts
July 31, 2012 at 8:48 am #462692<em>@activha 332391 wrote:</em><blockquote>Thanks, this avoids looping through the window but the side effect is that the pop up opens and then directly opens its content in a new window with tmpl=component.
What I would like to achieve is this but without the side effect :-)</blockquote>
Please try to update it to:
if(window.top!=window.self && !window.opener) {
window.top.location.href = window.location.href.replace(/(&*)tmpl=component/ , '&');
}activha Friendactivha
- Join date:
- July 2012
- Posts:
- 114
- Downloads:
- 17
- Uploads:
- 6
- Thanks:
- 5
- Thanked:
- 1 times in 1 posts
July 31, 2012 at 12:40 pm #462712Well this code opens it in the pop up window on the desktop and then automatically open it in a new window, so this is not it
I have tried
[PHP] if(window.top!=window.self && window.parent == window) {
window.top.location.href = window.location.href.replace(/(&*)tmpl=component/ , ‘&’);
}[/PHP]this works for desktop, for mobile this is not it yet. It opens the page in the same window so I have to manually go back with the browser button.
Do you have an idea to open it in a new window for mobile devices only ?
Wall Crasher DeveloperWall Crasher
- Join date:
- December 2011
- Posts:
- 1113
- Downloads:
- 0
- Uploads:
- 15
- Thanks:
- 66
- Thanked:
- 361 times in 300 posts
August 1, 2012 at 2:12 am #462755Hi activha,
Can you give a try with this and tell me the result ?
if(window.parent == window && !window.opener) {
window.top.location.href = window.location.href.replace(/(&*)tmpl=component/ , '');
}Hope it helps.
Regards
activha Friendactivha
- Join date:
- July 2012
- Posts:
- 114
- Downloads:
- 17
- Uploads:
- 6
- Thanks:
- 5
- Thanked:
- 1 times in 1 posts
August 1, 2012 at 8:50 am #462832Hi,
This code constantly loops on mobile devices, works on desktop though.The only one working for now is :
(window.top!=window.self && window.parent == window)with the only problem that it opens in the same window so users have to move back with the browser button
Wall Crasher DeveloperWall Crasher
- Join date:
- December 2011
- Posts:
- 1113
- Downloads:
- 0
- Uploads:
- 15
- Thanks:
- 66
- Thanked:
- 361 times in 300 posts
August 1, 2012 at 9:14 am #462835Hi activha,
Please tell me more detail about the loop issue.
Which devices you use for testing?And please give a try with this.
if(window.parent == window && !window.opener && window.location.href.test(/tmpl=component/gi)) {
window.top.location.href = window.location.href.replace(/(&*)tmpl=component/ , '');
}Hope it helps.
Regards
activha Friendactivha
- Join date:
- July 2012
- Posts:
- 114
- Downloads:
- 17
- Uploads:
- 6
- Thanks:
- 5
- Thanked:
- 1 times in 1 posts
August 4, 2012 at 9:12 am #463155I use iPhone 4S for testing,
This latest code seems to work ok but it had twice &tmpl=component at the end of the url.
I sticked with
[PHP]if(window.parent == window && !window.opener && window.location.href.test(/tmpl=component/gi)) {
window.top.location.href = window.location.href.replace(/(&*)tmpl=component/ , ”);
}[/PHP]which is working.
Wall Crasher DeveloperWall Crasher
- Join date:
- December 2011
- Posts:
- 1113
- Downloads:
- 0
- Uploads:
- 15
- Thanks:
- 66
- Thanked:
- 361 times in 300 posts
August 6, 2012 at 1:30 am #463245Hi activha,
I am not sure I can understand what you mean about the url has twice &tmpl=component at the end.
Anyway, I am happy that it work for you. :laugh:Regards
-
AuthorPosts
This topic contains 10 replies, has 3 voices, and was last updated by Wall Crasher 12 years, 3 months ago.
We moved to new unified forum. Please post all new support queries in our New Forum