Home >Web Front-end >JS Tutorial >JavaScript Beginner Tutorial (Lesson 3)_Basic Knowledge
The purpose of this lesson is to call the target name, in this case the window name yer_new_window.
Now that we have briefly reviewed the href target, it’s time to start learning to open windows in JavaScript.
Opening windows in HTML is extremely common, but there are also some drawbacks; users browse The browser determines what the window looks like; you have no control over the size or style of the window. Fortunately, JavaScript gives you this control.
Take a look at the reason:
window.open("URL","name","features");
This statement is based on the first one you used when calling A parameter URL to open a window. This is a URL, which can actually be written as "http://www.jsfan.org/basic" or something similar.
The second parameter is the name of the window. This is just like the names we saw on the previous page. If a window with the same name is already open when you open the window, the URL will send the open statement to the originally opened window.
The third parameter, features, is the different characteristics of a window. This is an optional parameter. Let’s do some exercises on the first two parameters first.
Here are some examples of opening windows with JavaScript.
Try clicking the three links below to see what will happen. Be careful not to close any of the three links before opening them. (The following three lines of text code were lost during the reprinting process, and the link has expired, so it cannot be clicked. I will correct it in the future----jsfan note)
This is a window named javascript_1.
A window named javascript_2.
Here is another HTML page that will enter javascript_1.
The first line of the statement:
Here's a window named javascript_1.
When you click the link, a window named javascript_1 Open the web page where javascript_window_1.html appears. Since the features parameter is optional, we will ignore it for now.
Note here that I use onClick to call the window. You don't have to put window.open() in onClick to call the window, it's easy to do. You'll see an example of windows.open() in a