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

Set target/Disable links #14

Open
uupat opened this issue Feb 20, 2019 · 3 comments
Open

Set target/Disable links #14

uupat opened this issue Feb 20, 2019 · 3 comments

Comments

@uupat
Copy link

uupat commented Feb 20, 2019

Is there a way that we can stop links from the embedded timeline from opening and taking over the app?

I am using this library in my Ionic 4 app and currently if you tap on the timeline on a mobile device, Twitter takes over the app. See the gif below for a recording of what's happening.

Imgur

@kwoxford
Copy link

Trap the clicks with document.body.onclick, check the source of the click if necessary, then open in a new window or inappbrowser.

        // find first parent with tagName
        function findParent(tagname, el) {
            while (el) {
                if ((el.nodeName || el.tagName).toLowerCase() === tagname.toLowerCase()) {
                    return el;
                }
                el = el.parentNode;
            }
            return null;
        }

 document.body.onclick = function (e) {
            const from = findParent('a', e.target);
            if (from) { ... }
} 

@uupat
Copy link
Author

uupat commented Mar 11, 2019

Trap the clicks with document.body.onclick, check the source of the click if necessary, then open in a new window or inappbrowser.

        // find first parent with tagName
        function findParent(tagname, el) {
            while (el) {
                if ((el.nodeName || el.tagName).toLowerCase() === tagname.toLowerCase()) {
                    return el;
                }
                el = el.parentNode;
            }
            return null;
        }

 document.body.onclick = function (e) {
            const from = findParent('a', e.target);
            if (from) { ... }
} 

Sadly this doesn't work, as the window.open function is caught first.

@ipehimanshu
Copy link

any solutions
I am trying to add embedded twitter timeline and here issue is when user click on that iframe tweet it hide current app web view and open twitter url, so fully weird things happen,
Any one have solution,
Thanks

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

3 participants