1

Normally, when I use <a href="_URL_"></a> in my metro application, the url is opening in the default web browser. I don't want to do this with anchor, I want to do the same behavior via Javascript and as async. But I don't know how to open the url with default browser.

Here is my code:

var $aTag = $("<a/>").click(function (event) {
    showYesNoDialog(
        "Do you approve?", 
        "The link will be opened in another window. Do you approve?", 
        "Yes", // Text of yes button
        "No",  // Text of no button
        function () { // Behavior of yes button
            // I tried this but nothing happened.
            window.location.href = _URL_; // Should open in chrome or default web browser
        },
        function () { // Behavior of no button
            // do nothing
        }
    );
});

What I also tried is that:

$("<a href='" + _URL_ + "'></a>").click();

But this didn't work, too.

sedran
  • 3,498
  • 3
  • 23
  • 39

2 Answers2

1

Finally, I found my answer while searching on google. Open a URL in a new tab (and not a new window) using JavaScript

I used this code to open the url out the metro app and it worked in my situation:

window.open(_URL_, '_blank');
window.focus();
Community
  • 1
  • 1
sedran
  • 3,498
  • 3
  • 23
  • 39
0

You cannot launch an actual application from within Metro, but what you can do is launch a file with associated program, and that should give you the functionality you need.

Check Sample

The sample covers files and URI's - http://msdn.microsoft.com/library/windows/apps/Hh701476

Dane Balia
  • 5,271
  • 5
  • 32
  • 57
  • I'm not dealing with files, I needed to open a web page. Thanks for interesting, finally I found my answer and I wrote it. – sedran Aug 15 '12 at 18:52