Solution to the problem that the web page special effects code in the controller cannot be executed in thinkphp tutorial
Take the item "exit" as an example.
My "Exit System" link is written in the frame on the left and dynamically generated using js. In other words, it cannot be specified through the target in the link.
view sourceprint?1 $this->assign('jumpurl',__url__.'/login');
$this->success("Logout successful!");
If you write it like this, the page you want to jump to will be displayed in the right frame.
Writing js code into the url will not work.
I commented out these two lines of code. Use directly
view sourceprint?1 echo "<script>window.top.location.href='$url';</script>";
This doesn't work either. On the one hand, the constants __app__ cannot be used in the URL. On the other hand, the final execution result is that the <script> tag is removed, and the rest is output directly! (window.top.location.href='index/login';)<br>
I checked the success function in the action class and found no relevant parameters. </p>
<p> </p>
<p>While having dinner at a friend’s place on Sunday, I suddenly thought of a question. The tags in tp are all enclosed by angle brackets (<>). Is the <script> I wrote in the controller being treated as Have the labels been parsed? So I re-wrote the second piece of code: </p>
<p><br>
view sourceprint?1 echo '<literal><script>alert("Exit successfully");top.location.href="login";</script>';
That’s it.