Saiid at RLTSquare Saiid at RLTSquare - 13 days ago 7
PHP Question

HTML in new Browser Tab or WIndow

In my PHP file, I have a string variable that contains complete HTML code.

$content = '<html>
<head>
<script>--Some javascript and libraries included--</script>
<title></title>
</head>
<body>
<style>--Some Styling--</style>
</body>
</html>';


I get this in a loop and now I want this HTML to open in new tab or window of browser. With every iteration, there would be a new Tab or Window. I don't think it is possible on server side so may be some JavaScript need to be concatenated to it.

Answer

In loop, I've created the URL to hit the controller and set the parameters with it and then simple use the following statement.

echo '<script type="text/javascript"> window.open("'. $url .'"); </script>';

and In the $url variable, I created the URL and post data in it. That's how, the new tab will open that hits the url and result will be my complete HTML.