Home > Backend Development > PHP Tutorial > ThinkPHP's solution to the problem that the javascript code in the controller cannot be executed_PHP tutorial

ThinkPHP's solution to the problem that the javascript code in the controller cannot be executed_PHP tutorial

WBOY
Release: 2016-07-13 10:54:25
Original
910 people have browsed it

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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632329.htmlTechArticlethinkphp tutorial. The web page special effects code in the controller cannot be executed. The solution is to exit. My exit system link is written into the frame on the left and dynamically generated using js...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template