I read many posts but i couldn’t find an answer to my question. I have a button on a webpage which is linked to a controller. This controller prepares some data and calls the view. In the view I have a php variable with this data.
I want to open a new page/tab and add the content of my php variable. The content of the variable is a SVG string which is readable by all browsers.
I know this is not possible in php. I need to use JavaScript, but how can i add the content of a php variable to a new tab???
Note: I have the string only in the php variable not in a file and I don’t want to click again on a link to open a new tab.
Any ideas or solutions?
According to the first answer an example (doesnt work:()
<html>
<head>
<title>
Test file
</title>
<script>
var myWindow = window.open('','_newtab');
myWindow.document.write($('myString').text());
</script>
</head>
<body>
<p style="display:none" id="myString">Das kommt auch auf die neue seite</p>
</body>
PHP is not capable of doing that. You need Javascript. Or you define your button with
target blank.Window open() Method http://www.w3schools.com/jsref/met_win_open.asp
HTML target Attribute http://www.w3schools.com/tags/att_a_target.asp
JS example:
This will open a new window and write #myString content to it. You need to define #myString with your string or whatever you want to display. E.g.
Here you go http://jsfiddle.net/qBjVG/13/