Home > Backend Development > PHP Tutorial > Solution to the problem that the javascript code in the ThinkPHP controller cannot be executed

Solution to the problem that the javascript code in the ThinkPHP controller cannot be executed

不言
Release: 2023-03-30 08:18:01
Original
2513 people have browsed it

This article mainly introduces the solution to the problem that the javascript code in the ThinkPHP controller cannot be executed. Using ThinkPHP's tag to solve the problem of javascript tags being parsed is a very practical technique. Friends who need it can refer to it.

The example in this article describes the solution to the problem that the javascript code in the ThinkPHP controller cannot be executed. Share it with everyone for your reference. The specific method is as follows:

Here is an example analysis of the solution to the problem that thinkphp's web page special effects code in the controller cannot be executed. Let's take the "Exit" item as an example. My "Exit System" link is written The one in the frame on the left is dynamically generated using js. In other words, it cannot be specified through the target in the link.

Copy code The code is as follows:

$this->assign(&#39;jumpurl&#39;,__url__.&#39;/login&#39;);<br>$this->success("注销成功!");
Copy after login

If written like this, the page to be jumped will be displayed in the right frame. Write the js code to It doesn't work in the url, I commented out these two lines of code. Directly use:

Copy code The code is as follows:

echo "<script>window.top.location.href=&#39;$url&#39;;</script>";
Copy after login

This will not work. On the one hand, the constants __app__ cannot be used in the url, on the other hand , the final result of the execution is that the

Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template