{"id":195,"date":"2006-03-16T13:15:12","date_gmt":"2006-03-16T18:15:12","guid":{"rendered":"http:\/\/fiveforks.com\/ted\/2006\/03\/open_a_window\/"},"modified":"2012-01-04T20:04:29","modified_gmt":"2012-01-05T01:04:29","slug":"open_a_window","status":"publish","type":"post","link":"https:\/\/www.fiveforks.com\/ted\/2006\/03\/open_a_window\/","title":{"rendered":"Open a Window"},"content":{"rendered":"<p>For the Engineers Association website, people submit newsletters to me as Word or PDF documents and ask me to post them to the website. I thought it would be good to have those open in a separate window since they are not html documents. I searched for the tag that would do that, but quickly found that it requires javascript. Also I found a site that said opening new windows was one of the top ten bad things that web designers can do because if the user wants to open a new window they can do it themselves and opening a new window messes up the Back button since you can&#8217;t go back from a new window (you have to close the window).<\/p>\n<p>The function I needed was window.open. I found a function that would do it and then you would call the function (in fact I used that when I made the covered bridge navigator), but I wanted it to all be in the link without a separate function call. By searching for &#8220;window.open&#8221; and &#8220;href&#8221; I found the exact same guy&#8217;s web page, written 4 years after his original warning to avoid opening a window, saying that for non-web documents it was best to open a new window because when people open a .pdf document they usually close the window to get rid of it and then lose their place and have to start the browser from scratch again (which is exactly what I always do). However he did not provide any code on how to do this. I soon found a really good way to do it by using the HREF to go to the .pdf file, but adding an onClick that would cause a new window to open. Then you have the best of both worlds: when someone mouses over the link they see where they are going, they can even download the file by right-clicking it, and the link still works even if they&#8217;ve turned javascript off. But if they have javascript running, it will open a new window when they click it.<\/p>\n<p>The code below opens a new resizable window 700 pixels wide (enough for letter size width) by 500 pixels vertical, without toolbars:<\/p>\n<p>&lt;a href=&#8221;newsatl06.pdf&#8221; onClick=&#8221;window.open(&#8216;newsatl06.pdf&#8217;,&#8217;mywin&#8217;,&#8217;left=20,top=20,width=700,height=500,toolbar=0,resizable=1&#8242;); return false&#8221;&gt;February 2006 Newsletter&lt;\/a&gt;<\/p>\n<p>You can also <A HREF=\"http:\/\/www.gdotea.com\/atlanta\/news.html\">see it in action<\/A><\/p>\n","protected":false},"excerpt":{"rendered":"<p>For the Engineers Association website, people submit newsletters to me as Word or PDF documents and ask me to post them to the website. I thought it would be good to have those open in a separate window since they are not html documents. I searched for the tag that would do that, but quickly &hellip; <a href=\"https:\/\/www.fiveforks.com\/ted\/2006\/03\/open_a_window\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Open a Window&#8221;<\/span><\/a><\/p>\n","protected":false},"author":15,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-195","post","type-post","status-publish","format-standard","hentry","category-web"],"_links":{"self":[{"href":"https:\/\/www.fiveforks.com\/ted\/wp-json\/wp\/v2\/posts\/195","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.fiveforks.com\/ted\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fiveforks.com\/ted\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fiveforks.com\/ted\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fiveforks.com\/ted\/wp-json\/wp\/v2\/comments?post=195"}],"version-history":[{"count":1,"href":"https:\/\/www.fiveforks.com\/ted\/wp-json\/wp\/v2\/posts\/195\/revisions"}],"predecessor-version":[{"id":1042,"href":"https:\/\/www.fiveforks.com\/ted\/wp-json\/wp\/v2\/posts\/195\/revisions\/1042"}],"wp:attachment":[{"href":"https:\/\/www.fiveforks.com\/ted\/wp-json\/wp\/v2\/media?parent=195"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fiveforks.com\/ted\/wp-json\/wp\/v2\/categories?post=195"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fiveforks.com\/ted\/wp-json\/wp\/v2\/tags?post=195"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}