IE Handling when eval encounters function_javascript skills
Case 1: There is no function in eval, execute it directly:
eval("alert('ss');");//All browsers correctly output
Case 2: There is a function in eval, and the function is executed immediately:
eval("(function(){alert('ss');})();");//All browsers output correctly
Case 3: There is a function in eval, use a variable to save the function reference and Call this function:
var f=eval("(function(){alert('ss');})");
f();//Error reported under IE: Missing object, other browsers are normal
When defining a function in eval and returning it to a variable, IE reports an error: Missing object. It can be seen that the function defined in eval under IE cannot be successfully returned to outside eval.
Solution: Return the function object as an execution result:
Method 1:
var f=eval("(function(){ return function(){alert ('ss');}})()");
f();//All browsers correctly output
eval to call a function that is executed immediately. After the function is executed, it returns a function object. This When the reference of the function object is successfully returned to the external variable.
Method 2:
var f=eval("(false||function(){alert('ss');})");
f();// All browsers successfully output
. This method is also used in jquery. The function is returned as the execution result of the or expression, which can also successfully solve the problem. Of course, expressions are not limited to the above false||function(){}. Various expressions can solve the problem as long as they can successfully return function:
/* and expressions: */
var f=eval("(true&&function(){alert('ss');})");
f();//All browsers output normally
/* ternary expression :*/
var f=eval("(true?function(){alert('ss');}:'');");
f();//All browsers output normally

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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











Function means function. It is a reusable code block with specific functions. It is one of the basic components of a program. It can accept input parameters, perform specific operations, and return results. Its purpose is to encapsulate a reusable block of code. code to improve code reusability and maintainability.

eval means "evaluation" and is a built-in function in Python that is used to execute a string expression and return the calculation result of the expression; that is, when assigning a variable, the representation on the right side of the equal sign is written in the format of a string, The return value is the result of this expression. Syntax "eval(expression[, globals[, locals]])".

How to disable eval in PHP under win: 1. Download "PHP_diseval_extension"; 2. Find the PHP currently used by the server; 3. Open the PHP configuration file; 4. Add the "extension=diseval.so" code; 5. Restart the service.

In this article, we will learn about enumerate() function and the purpose of “enumerate()” function in Python. What is the enumerate() function? Python's enumerate() function accepts a data collection as a parameter and returns an enumeration object. Enumeration objects are returned as key-value pairs. The key is the index corresponding to each item, and the value is the items. Syntax enumerate(iterable,start) Parameters iterable - The passed in data collection can be returned as an enumeration object, called iterablestart - As the name suggests, the starting index of the enumeration object is defined by start. if we ignore

Detailed explanation of the role and function of the MySQL.proc table. MySQL is a popular relational database management system. When developers use MySQL, they often involve the creation and management of stored procedures (StoredProcedure). The MySQL.proc table is a very important system table. It stores information related to all stored procedures in the database, including the name, definition, parameters, etc. of the stored procedures. In this article, we will explain in detail the role and functionality of the MySQL.proc table

In Python, the eval() function is used to execute a string expression and return its result. It takes a string containing an expression as a parameter and evaluates the expression. The eval() function is powerful, but it should be noted that it will execute any valid Python expression contained in the string, so you should avoid accepting external input strings when using it to prevent security vulnerabilities.

Usage and Function of Vue.use Function Vue is a popular front-end framework that provides many useful features and functions. One of them is the Vue.use function, which allows us to use plugins in Vue applications. This article will introduce the usage and function of the Vue.use function and provide some code examples. The basic usage of the Vue.use function is very simple, just call it before Vue is instantiated, passing in the plugin you want to use as a parameter. Here is a simple example: //Introduce and use the plug-in

The clearstatcache() function is used to clear the file status cache. PHP caches the information returned by the following functions −stat()lstat()file_exists()is_writable()is_readable()is_executable()is_file()is_dir()filegroup()fileowner()filesize()filetype()fileperms() What to do To provide better performance. Syntax voidclearstatecache() Parameter NA Return value clearstatcache(
