question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue with opening share url in a new tab

See original GitHub issue

Link example http://radiko.jp/share/?t=20210329153524&sid=JORF

On Edge 89.0.774.63, (sometimes?) it will stuck in a loop (share -> radio page -> radiko out -> share -> radio page -> radiko out …) On Brave 1.22.70, it will navigate back to the empty new tab

I guess it’s related to the recent change and somehow each browsers dealt with it differently.

if (window.location.hash == "#!/out"){
    $.colorbox.close();
    history.back()
}

Idea : Instead of relying on location hash, is it possible to deal with this directly?

area.js

            $.Radiko.ajax('/area', function (data, status, xhr) {
                /* snipped */
                var areaFreeId = $.cookie('areafree_id');
                if (typeof areaFreeId !== 'undefined') {
                    $.Radiko.area.id = areaFreeId;
                }
                else {
                    $.Radiko.area.id = defaultAreaId;
                }
                $.Radiko.header.create_header(getAreaId(), loginStatus);
            }, function () {
                $.Radiko.area.id = 'OUT'; //<---------
            }, 'text', true).always(function () {
                if ($.Radiko.area.id === 'OUT') {
                    window.location.hash = '#!/out';
                }
                $.Radiko.EventEmitter.trigger('radikoready');
            });

The extension blocking ajax call to /area which make them to assign the default value of $.Radiko.area.id to “OUT”. This seems to be the ultimate final check that causing user to be redirected to #!/out .

Override $.Radiko.area.id to any value (or to the relevant value from cookie) after they assign “OUT”, and user will get a proper web page.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jackyzy823commented, Sep 30, 2021

Finally . I decide to hijack jquery.ajax to make $.Radiko.area.check_area 's error function not work and set a $.Radiko.area.id to bypass OUT issue.

Dirty work. Dirty code. but make sense.

0reactions
jackyzy823commented, Apr 10, 2021

Thanks for your test.

I might found the key to the problem.

  1. area -> modify hash to OUT
  2. path.js first initialization will do a dispatch which use OUT if (location.hash !== “”) { Path.dispatch(location.hash); }
  3. my hashchange listener will modify hash to origin
  4. path.onhashchange will dispath to origin

and step 2 and ( 3 + 4 ) order is not guaranteed. so if 3+4 before 2 then it will go to right origin url then go to OUT

So the only way is to add some delay. 😞

Read more comments on GitHub >

github_iconTop Results From Across the Web

Open a URL in a new tab (and not a new window)
This is a trick, function openInNewTab(url) { window.open(url, '_blank').focus(); } // Or just window.open(url, '_blank').focus();.
Read more >
links won't work - unless I FIRST "open in new tab", then they do
It would seem to me that the link should either work or not work, but not depend on opening in a new tab...
Read more >
Linking to a new tab vs. same tab - UX Collective
Opening links, whether they are to the same website or another, in a new tab can pose a variety of issues for users,...
Read more >
How to Open URL in New Tab using JavaScript
To open a new tab, we have to use _blank in the second parameter of the window.open() method. · The return value of...
Read more >
How to Make HTML Links Open in a New Tab - YouTube
Learn how to open links on your website in a new tab with purely HTML by using the target="_blank" attribute of the a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found