ThinkPHP javascript code in the controller cannot be executed solution _ PHP Tutorial

Source: Internet
Author: User
ThinkPHP's javascript code in the controller cannot be implemented. In the thinkphp tutorial, if the webpage special effect code in the controller cannot be executed, exit this item. My exit system link is written to the framework on the left. using js to dynamically generate thinkphp tutorial, the webpage special effect code in the controller cannot be implemented.
Take the "exit" option for example.
My "exit system" link is written to the framework on the left, which is dynamically generated using js. That is to say, the target in the link cannot be specified.

View sourceprint? 1 $ this-> assign ('jumpurl' ,__ url _. '/login ');
$ This-> success ("logout successful! ");

In this way, the page to jump to is displayed in the right frame.
Writing js code to a url is not acceptable.
I commented out the two lines of code. Direct use


View sourceprint? 1 echo "script window. top. location. href = '$ url'; script";


This does not work either. On the one hand, the _ app _ constants cannot be used in the url. On the other hand, the final execution result is to remove the script tag and output the rest directly! (Window. top. location. href = 'index/login ';)
I checked the success function in the action class and found no relevant parameters.

When I was eating at a friend's house on Sunday, I suddenly thought of a problem. The tags in tp are included in angle brackets (<>, is the script I wrote in the controller parsed as a tag? So I re-wrote the second code:


View sourceprint? 1 echo' Script alert ("exited successfully"); top. location. href = "login"; script ';

That's all.

Quit. My exit system link is written to the framework on the left, which is dynamically generated using js...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.