<form target="_blank"> deprecated, work around?

Soldato
Joined
4 Mar 2010
Posts
5,038
Hi chaps I am making myself a mini cms.

I would like to make a preview button using submit before an article goes live, the thing is once the preview is shown and once I hit back on my browser I lose all the post data,so the way around it would be to open in a new window right?

How would one open the preview in a new window if target="_blank" is deprecated?
 
Could you make the preview button send the data to the page you're currently on, keeping all the text in the form aswell?

Eg.
Code:
if($preview=true){
//show the preview
//fill the form with the post data
}
//form code here
 
Could you make the preview button send the data to the page you're currently on, keeping all the text in the form aswell?

Eg.
Code:
if($preview=true){
//show the preview
//fill the form with the post data
}
//form code here

Nah not really, it is a true preview of what it would look like as if it were on a live page so, no forms...

Although I could do display:none; hmmm.

Also is there a way for javascript to pass post data using?

<input type="button" onlclick=" " />
 
I'm no good at javascript, I can't help you with that one, but I've got another way to do this, assuming it's like what I think it is.

Have it so the articles can be saved as either a draft or published.
On the page where you write your article, make the button 'Save Draft'.
Make this bring you to the 'live page', but only people logged in as admin can see it.
Then have buttons at the bottom labelled 'Publish', if it's ready for the public, and 'Edit' to take you to a page to edit it.

Draft page will be eg.
Code:
if($admin = true && $draft = true){
//show article
//show publish button
}else if($admin = false && $draft = true){
//show error of some kind
}else{
//show article as normal
}

This will also mean that you can let other admins see your article before you publish it.
 
Could always use a button to offer use to make changes on the preview page "Anything wrong? Click 'here' to edit'" and then have the link a hidden submit, send all the information hidden back to the original page. Then in the form set the values to the returned information IF there is any.
 
There's a hacky workaround that a lot of people are using... basically, use some JS to inject the target="_blank" or onclick="window.open(this.href)" attribute in the document's onload, based on a class or rel value; as demonstrated on this link:
http://www.serve.com/apg/workshop/replacingTarget/

However, popups (legitimate or not!) are considered the webs worst element. :)
 
Sorted!

I used a block of isset to determine conditions and kept action as php_self and the post data seems to stay in focus, horaay!

I was worried that I would have to do something hacky(yuck!)

Here is my solution
PHP:
<?php
require_once($_SERVER['DOCUMENT_ROOT'].'/includes/php/admin_core_class.php');

if(isset($_POST['preview']))
	{
		#will show true preview of article
		require_once($_SERVER['DOCUMENT_ROOT'].'/includes/php/site_core_class.php');
		require_once($_SERVER['DOCUMENT_ROOT'].'/includes/php/preview_class.php');
		$preview = new preview();
	}
	elseif(isset($_POST['complete']))
	{
		#will upload article to db
		echo "UPLOADING ARTICLE!!!";

	}
	else
	{
		#will load creation form
		require_once($_SERVER['DOCUMENT_ROOT'].'/includes/php/site_core_class.php');
		require_once($_SERVER['DOCUMENT_ROOT'].'/includes/php/articles_class.php');
		$page = new articles('Create Article');
		$page->load_create_form();
		$page->loadJs();
	}
?>
 
Back
Top Bottom