PayPal JavaScript integration - open new tab - javascript

I saw some websites open new tab on paypal button click. I'm trying to implement the same behaviour but cannot find the way how to do that. It always opens the pop-up on the same page.
Is there a way of doing it with JavaScript intagration.
The method I use https://developer.paypal.com/docs/checkout/#
If you go by the link above and click on paypal button (demo example) it will open a popup where you do your payment and then it closes. I want the same to happen in new tab instead of popup.

You would need to not integrate with the PayPal Checkout JS, and instead create your own button and write your own JS to open the Orders V2 API redirect_url in a new tab when your button is clicked.
There is no reason you should want to do this, however. The popup is in fact a better, modern "in context" experience that keeps your site open and loaded in the background. It is in fact more user-friendly in this respect. I remember from the days when this popup was first released, PayPal spent spent a lot of effort getting the experience right and making sure it performed better, i.e. resulted in more users going through with and completing the checkout, than going away to a new separate tab (that might be unfamiliar). You can trust PayPal on this, it's the company's bread and butter.

Related

Continue JavaScript after open new Tab via Button Click

I'm quiet new to JavaScript and need your help concerning the following problem:
I've written a JavaScript to subscribe automatically to a gym class every monday at 7 a.m..
I have to click a button that's opening a new tab where I have to fill my personal data. The URL of the new tab is variable so I cant do it via
window.open(URL,"_self")
Is there a way to continue the script in the new tab or open the website in the same tab?
Thanks!
Because of the objections mentioned, that doesn't sound feasible to me - at least in this form. If you want to run a script on the external website, then simply use a browser solution such as:
Tampermonkey (https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo?hl=en)
Greasemonkey (https://addons.mozilla.org/de/firefox/addon/greasemonkey/)
There you can install your script and have it automatically fill out your registration.
If you want to automate this completely without doing anything on your part, then you will not be able to avoid an (external server-side) solution such as a NodeJS application with puppeteer (https://github.com/puppeteer/puppeteer) running every X days.

Can you make an html link that does not let you click back to previous page, or show the previous link in your history?

I am working on a client site where the client has requested that there be a button (basic a link) that links to another page like google, in case an abusive significant other busts into the room while a woman is reading about how to get assistance. The tricky part is that I am trying to figure out to link to a page that will open int he same windows, but no let you go back to the site by clicking the browser's back button, or show up in "history". I have built a lot of website and never heard of this being possible without the use of a custom browser extension or something.
My question is ..
Is there a way to do this? Possible some JS magic? Just wondering
You're looking for location.replace().
<button onclick='location.replace("https://www.google.com");'>Click to close</button>
Instead of creating a new entry in browser history, it replaces the current one.
Note: Unfortunately, it's blocked by [SO]. But just try it in your app. It does work.
Second note: If you combine this with initially opening the to be hidden page in a new tab (target="_blank") => no history.
However, the best method and advice for such cases is browsing in incognito: Ctrl+Shift+N. Once closed, it's gone, with all history in the session. Pressing Ctrl+Shift+T in a new browser window won't bring the formerly opened tabs back.
IMHO, this technique should be clearly detailed in the "Precautions" section of your client's website, also advising on having another "normal" browsing session opened in a background browser window, with a few neutral tabs open on subjects that wouldn't raise any suspicions: cooking recipes, things for children, cosmetics, etc...
I am not sure about your question.
But on click you can open Iframe
<iframe src="www.google.com" style="border:none;"></iframe>

How do I open a link to a website on a new window in a browser and block the current website until the user finish or close the new one?

Currently I'm working with Mercado Pago API, but the thing is that I want when the user clicks the pay button, I want to open a new window in the browser (chrome, firefox, etc.) in the middle of the screen where is going to fill his credit card number and all that stuff meanwhile i want that the background site (I mean the main site where the user clicked on pay) to be blocked, like with darker colors, and not be able to do anything in that site until the user close the new window or he finish with the payment. I've been looking on the internet but I haven't found anything related to the blocked site. Maybe you could help me or have any idea to make that. thanks in advance.
I can't make comments, so sorry in advance for this being an "answer". But are you not able to store information about what the user has selected and then use the current page to process the payment, then bring back or send off what they wanted? perhaps using AJAX to run a PHP page that stores something. Just a suggestion but not entirely an answer, because AFAIK you can't "block" tabs as that could be very dangerous and could be used for the wrong reasons.
The task you want to do requires both back-end programming (php/server-side) and a bit of front-end jquery(js) + ajax.
For front-end something like this could be your start.
Bootstrap Static Modal Example.
And you would need to put your form there, submit it via ajax, and on success close the modal.
I hope this could help you a bit, and get you started in the right direction.
Note: This is not particularly safe. (It's not hard to hide the modal and fiddle around the page in the background.

How to invoke onbeforeunload behavior for static page in JS?

I have a document that can not be quit without saving changes. I use onbeforeunload to ask user if he really wants to quit. It works fine if the "quitting" scenario is clicking on a link and reloading page. but i have also JS menu that moves user from document editor to settings and it's done without website redirect but is handled wholly by JS by replacing "document view" and showing "edit settings view". But moving to edit settings view makes the changes in document unsaved like a normal reload does. So how to invoke browser to ask if user really wants to move to edit settings view like it does when page reload occurs in this scenario?
You can't, without navigating away from the page. But you can ask them with a much nicer, more friendly modal dialog of your own (an absolutely positioned div with a zIndex greater than any other, possibly with an iframe shim under it to eat all clicks, etc.). You can roll your own, but there are lots of modal dialog libraries out there which would save you time.
Or if you like, you can use confirm, which doesn't have a very good user experience (but then, neither does onbeforeunload) but is dead easy to code and entirely cross-browser compatible (despite the link being to a Mozilla page).

Is it a bad idea to use window.open and try to communicate between windows?

I'm working on a web page that will have a google-reader type scrolling list of content, and I'd like to open that content when it's clicked on in a new window. The problem is that I'd really like to be able to update the scrolling list from one of the newly opened windows.
For example; I'm looking at a list of products for sale on my web page, and a user clicks one of the products, opening a new page displaying details of the product they clicked on. The new page also includes links to various assortments of products (lets say teacups) - when the user clicks on 'show me some teacups', I'd like the original list of products to be redirected to the page showing all the teacups and focus to be transferred to this window (leaving the product-specific page open in another window/tab)
Is this a horrible idea? Will I have problems with popup blockers or security policies in newer browsers? Is this generally considered a bad design pattern?
Thanks for any input.
Popups are a delicate matter these days because of popup blockers. If at all possible, using inline dialog boxes like JQuery dialog is preferable - they all reside within one page, though, of course. But they're resizable, can be made modal and much more.
Other than that, as long as all your windows come from the same domain, I don't see any problems with cross-window communication, as long as you have only one parent that opens all the windows and that can serve as a broker in intra-window communication (the popup windows know only window.opener).
OK, so to answer my own question (I need to stop asking questions before I really dig for answers), this is a very bad idea indeed - I knew it felt wrong. The basic problem is that it breaks the back button, which could potentially be remedied with some JS goodness, but it's still a bad idea from an accessibility standpoint. My guess is that the reason Google Reader does this by default is that it's explicitly an interface for viewing other pages, so the user shouldn't be surprised to find that the links open in new windows.
Some reading on the topic for anyone interested:
Top 10 Web Design Mistakes of 1999
W3C Mailing list discussion of a.target deprecation

Categories

Resources