0

With this JavaScript linker.js: I want to open a new window and redirect to a webpage outside the current website, Here is my code:

    deps  = ['jquery'];
    define (deps, function($) {
    var linker = {
        'link' : function(ortholog,link) {
            $form = $('<form>');
            $form.attr("method","POST");
            $form.attr("action",link);
            $form.attr("target","_blank");
            $input = $("<input>");
            $input.attr("type","hidden");
            $input.attr("value",ortholog);
            $form.appendChild($input);

            $form.submit();
        }
        //return linker();
    }
    return linker;
});

I am facing problem similar to url.Action open link in new window on ASP.NET MVC Page

How can I move out of my current website?

Community
  • 1
  • 1
user2998764
  • 445
  • 1
  • 6
  • 22
  • The value of `action` will be a `Event` object. `action+ortholog` doesn't make any sense. – Barmar Jun 28 '14 at 04:55
  • In my code link is the path that I want it to redirect to and ortholog is an id which was intended to be concatenated with the above path and form a full URL. – user2998764 Jun 28 '14 at 05:00
  • So maybe it should be `window.open(link+ortholog)` – Barmar Jun 28 '14 at 05:01
  • I have tried that too, but I end up with a URL concatenating my present website URL and the path (to which I wanted it to redirect to ) similar to http://stackoverflow.com/questions/2381949/url-action-open-link-in-new-window-on-asp-net-mvc-page – user2998764 Jun 28 '14 at 05:05
  • I'm having a real hard time figuring out what you're tring to do. `$form.attr("action", link)` means that `link` is where you want the form submitted to. How can it also be the URL you want to redirect to? And why doesn't the form you're creating have any input fields? – Barmar Jun 28 '14 at 05:15
  • Yes I realized my mistake with input field, (new to web programming). This is how my understanding goes about action(maybe terribly wrong), say I want to redirect to www.yahoo.com I would write $form.attr("action",www.yahoo.com); – user2998764 Jun 28 '14 at 05:22
  • I still don't understand what all this form stuff is for. Why don't you just do `window.open("www.yahoo.com")`? – Barmar Jun 28 '14 at 05:33
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/56450/discussion-between-user2998764-and-barmar). – user2998764 Jun 28 '14 at 05:43

0 Answers0