Difference between button onclick and a href

DFB

I'm trying to integrate SendOwl shopping cart into my application (details of the application are at the end).

To demo the problem I created a simple snippet using pure HTML / Javascript. In the head section of the HTML, I have this:

<script type="text/javascript">
    function SendOwl(url) {                 
        window.location.href=url;
    }
</script>
<script type="text/javascript" src="https://transactions.sendowl.com/assets/sendowl.js" ></script>

In the body I have this:

Example 1: Opens the checkout form in its own window (Undesired behavior):

<input type="button" onclick="SendOwl('https://transactions.sendowl.com/products/8/5C080C0F/purchase');" value="On Click" />

Screenshot 1: Notice the URL changed and it's not an overlay (compared to 2).

enter image description here

Example 2: Opens the checkout form in a modal window as an overlay (Desired behavior):

<a href='https://transactions.sendowl.com/products/8/5C080C0F/purchase'>a href</a>

Screenshot 2: The URL stays the same, but the form opens in an overlay.

enter image description here

You can also see a live demo on the SendOwl's demo page.

My application is based on GWT (SmartGWT to be precise). In my application, I call button onclick handler to invoke a Javascript that invokes the Buy Now link using JSNI call (shown below). But the Buy Now link always opens in a full window as in example 1 above.

public static native void onBuyNowClick(String url) /*-{
  $wnd.SendOwl(url);
}-*/;

I have tried $wnd.open(url) but that has the same behavior.

How do I get the first example to behave like the second but still using button onclick?

UPDATE:

The magic is in the sendowl.js script. If I remove that script, then both examples work the same way. If I could figure out how that script works, it might give some clues to make Example 1 work the same way as Example 2.

Thanks.

DFB

I have resolved the issue myself by probing into the sendowl.js . That's the script which is doing all the magic.

This is my modified script that makes Example 1 work exactly like Example 2:

<script>
    function SendOwl(url) { 
        sendOwl.addLoadingImage();
        sendOwl.loadIframe ('https://transactions.sendowl.com/products/8/5C080C0F/purchase');
    }
</script>
<script src="https://transactions.sendowl.com/assets/sendowl.js"></script>  

Thanks to all who replied and tried to help.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

what is the difference between <button onclick=...> and <a href="#" onclick=.../>

From Dev

Converting an <a href=...> to a button onclick

From Dev

Difference between "click" and onclick

From Dev

Difference between "href" and "ng-href" in AngularJS

From Dev

What is the difference between href="//..." and href="https://..."

From Dev

bootstrap button onclick and location.href

From Dev

Whats the difference between onclick and onsubmit?

From Dev

Alternate between URLs for each onclick of href

From Dev

Actual difference between TextView and Button

From Dev

Difference between import * as Button and import {Button}

From Dev

JSF difference between action, actionlistener, onClick

From Dev

difference between onTouch and onClick listener and use of multithreading

From Dev

Dynamically create element but use <a href> instead of a button onClick

From Dev

javascript button onclick to a web uri with location.href

From Dev

add dynamic onclick="location.href= to button via js

From Dev

How to toggle between bootstrap button classes onClick?

From Dev

what is the difference between Button button=(Button) findViewbyID(R.id.button); and Button button = new Button; in Android?

From Dev

difference between Button button = (Button) v; and Button button = (Button)findviewbyid(r.id.button1);

From Dev

What's the difference between <button> and <button type="button">

From Dev

What's the difference between <button> and <button type="button">

From Dev

Differences between <button> and <input type="button"> for onclick script handling

From Dev

Time difference between button presses swift

From Dev

Difference between button and which in mouse events

From Dev

iOS Button Difference Between Simulator and Device

From Dev

Difference between back press and home button in android

From Dev

What's the difference between submit and button?

From Dev

Is there a difference between a button being deactived and disabled?

From Dev

What's the difference between href and path in Url.parse() object?

From Dev

What is the difference between location.replace and location.href?

Related Related

  1. 1

    what is the difference between <button onclick=...> and <a href="#" onclick=.../>

  2. 2

    Converting an <a href=...> to a button onclick

  3. 3

    Difference between "click" and onclick

  4. 4

    Difference between "href" and "ng-href" in AngularJS

  5. 5

    What is the difference between href="//..." and href="https://..."

  6. 6

    bootstrap button onclick and location.href

  7. 7

    Whats the difference between onclick and onsubmit?

  8. 8

    Alternate between URLs for each onclick of href

  9. 9

    Actual difference between TextView and Button

  10. 10

    Difference between import * as Button and import {Button}

  11. 11

    JSF difference between action, actionlistener, onClick

  12. 12

    difference between onTouch and onClick listener and use of multithreading

  13. 13

    Dynamically create element but use <a href> instead of a button onClick

  14. 14

    javascript button onclick to a web uri with location.href

  15. 15

    add dynamic onclick="location.href= to button via js

  16. 16

    How to toggle between bootstrap button classes onClick?

  17. 17

    what is the difference between Button button=(Button) findViewbyID(R.id.button); and Button button = new Button; in Android?

  18. 18

    difference between Button button = (Button) v; and Button button = (Button)findviewbyid(r.id.button1);

  19. 19

    What's the difference between <button> and <button type="button">

  20. 20

    What's the difference between <button> and <button type="button">

  21. 21

    Differences between <button> and <input type="button"> for onclick script handling

  22. 22

    Time difference between button presses swift

  23. 23

    Difference between button and which in mouse events

  24. 24

    iOS Button Difference Between Simulator and Device

  25. 25

    Difference between back press and home button in android

  26. 26

    What's the difference between submit and button?

  27. 27

    Is there a difference between a button being deactived and disabled?

  28. 28

    What's the difference between href and path in Url.parse() object?

  29. 29

    What is the difference between location.replace and location.href?

HotTag

Archive