0

I have the following code;

<div class="firm_name">
<form action="#">
<input type="text" value="" id="name" maxlength="28" />
<p class="spacer2"></p>
<span class="form_text" style="display:block; height:28px; position:relative;"><a href="#" onclick="window.print();window.location.href='thanks.html';"><img src="images/print.png" style="border:none;"/></a></span>
</form>
</div>

It works fine if I wanted to print the new page but I want to display the content in a new page instead of printing it.

Can anyone help?

Thank you.

2 Answers2

0

Change window.print(); for window.open('yourURL.com');

Sebastien
  • 1,308
  • 2
  • 15
  • 39
  • that just opens the window, doesn't pass the data. – bitoiu Sep 11 '13 at 18:40
  • If he want to pass the data to a new page, he'll have to use php form submitting or an AJAX request. On either case to open a new window in javascript my answer does what is ask – Sebastien Sep 11 '13 at 18:41
0

If you want to open a new window you will need to generate a page and a url for that on your server.

You can simulate a window by opening a iframe on a modal inside your page, which is not the best, but it provide the isolation to be able to print.

Or if you want to open it via javascript, you can do it, but most browsers nowadays don't like it, some will prompt permission for the user, and some will block silently.

If you really want to "open a new window" anyways here is some code http://jsfiddle.net/Victornpb/eWVC2/

function pop(html,top,left,width,height) {

    var popup = window.open("", "", "width="+width+",height="+height+",top="+top+",left="+left+",toolbar=no");
    if(popup){
        popup.document.open();
        popup.moveTo(top,left);

        popup.d = popup.document;
        popup.d.write(html);
    }
    else{
        alert("Popup blocked!");
    }
    return popup;
}
Vitim.us
  • 20,746
  • 15
  • 92
  • 109