ThinkPHP控制器里javascript代码不能执行的解决方法_php实例
本文实例讲述了ThinkPHP控制器里javascript代码不能执行的解决方法。分享给大家供大家参考。具体方法如下:
这里实例分析一下thinkphp在控制器里的网页特效代码不能执行解决方法,就拿“退出”这一项来说吧,我的“退出系统”链接是写到左边的框架里的,用js动态生成的。也就是说,没法通过链接里的target来指定。
$this->success("注销成功!");
这样写的话,要跳转的页面就显示在了右框架里了,把js代码写到url里面不行,我把这两行代码注释掉了。直接用:
这样也不行,一方面url里面没法用__app__这些常量,另一方面,最后执行出来的结果是竟是把<script>标签去掉,剩下的直接输出!<br /> <div class="codetitle"><span><a style="CURSOR: pointer" data="54152" class="copybut" id="copybut54152" onclick="doCopy('code54152')"><U>复制代码 代码如下:<div class="codebody" id="code54152">(window.top.location.href='index/login';)<br /> 我查了action类里的success函数,没有找到相关的参数。 <p>后来突然想到一个问题,tp里的标签都是以尖括号(<>)来包含的,我在控制器里写的<script>是不是被当作标签给解析了呢?于是我就重新写了第二段代码:<br /> <div class="codetitle"><span><a style="CURSOR: pointer" data="93673" class="copybut" id="copybut93673" onclick="doCopy('code93673')"><U>复制代码 代码如下:<div class="codebody" id="code93673">echo '<literal><script>alert("退出成功");top.location.href="login";</script>';
这样就行了。
希望本文所述对大家的ThinkPHP框架程序设计有所帮助。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In daily office and study, printers are indispensable tools. However, encountering printer errors is a very common situation. Recently, some users have encountered error code 0x0000709 when using the printer, and the system prompts that the operation cannot be completed. We have prepared four solutions to this problem, let’s take a look. Method 1: NT6 Printer Sharing Repair Tool The NT6 Printer Sharing Repair Tool is an excellent printer repair tool that can easily solve the problem of printer sharing link failure caused by updating patches, such as the recent problem when connecting Win10 and Win11 to share a printer. Errors reported, printer error codes 0x0000011b, 0x00000709 and other issues. This tool provides

ThinkPHP has multiple versions designed for different PHP versions. Major versions include 3.2, 5.0, 5.1, and 6.0, while minor versions are used to fix bugs and provide new features. The latest stable version is ThinkPHP 6.0.16. When choosing a version, consider the PHP version, feature requirements, and community support. It is recommended to use the latest stable version for best performance and support.

Deepseek is a platform that provides anonymous deep network access. To access its official website, please use the official portal link provided. If you encounter problems during login, it may be due to the following reasons: the browser is outdated, the credentials are incorrect, the connection is blocked, maintenance or the account is disabled. Frequently Asked Questions include: Deepseek's security and legality, and how to connect with the support team.

The homepage file in the ThinkPHP framework is used to define the homepage of the website. It is located at app/home/controller/IndexController.php and contains an action method named index, which is responsible for processing homepage requests. This method contains the business logic of the homepage and returns the view file app/home/view/index/index.html.

DeepSeek: How to deal with the popular AI that is congested with servers? As a hot AI in 2025, DeepSeek is free and open source and has a performance comparable to the official version of OpenAIo1, which shows its popularity. However, high concurrency also brings the problem of server busyness. This article will analyze the reasons and provide coping strategies. DeepSeek web version entrance: https://www.deepseek.com/DeepSeek server busy reason: High concurrent access: DeepSeek's free and powerful features attract a large number of users to use at the same time, resulting in excessive server load. Cyber Attack: It is reported that DeepSeek has an impact on the US financial industry.

Gate.io Exchange provides users with an official login portal. Through the official website or mobile app, users can log in to their account. The login steps are easy, including entering the email or mobile phone number used when registering, as well as your password. In order to ensure the security of the account, it is recommended that users change their passwords regularly and properly keep their login information. In addition, the article also provides solutions to common login problems, including inability to log in and password loss.

For beginners, Laravel has a lower entry barrier and is easier to get started. The reasons include: 1. Simpler installation and configuration; 2. Rich documentation and community support; 3. Simple and easy-to-understand syntax and API; 4. Smooth learning curve. In specific scenarios, PHP beginners are recommended to choose Laravel, while experienced developers can consider the flexibility of ThinkPHP.

How to adjust Sesame Open Exchange to Chinese? This tutorial covers detailed steps on computers and Android mobile phones, from preliminary preparation to operational processes, and then to solving common problems, helping you easily switch the Sesame Open Exchange interface to Chinese and quickly get started with the trading platform.
