HTML 网页 间利用 JavaScript 通过 URL 传递变量_PHP
<font size="2"><font face="verdana,arial,helvetica">PHP代码:</font><hr></font><code><font color="#000000"> <font color="#0000bb"><br></font><font color="#007700"><font color="#0000bb">SCRIPT language</font><font color="#007700">=</font><font color="#0000bb">javascript</font><font color="#007700">> <br> <br></font><font color="#ff8000">/* html_list.js HTML 网页 间利用 JavaScript 通过 URL 传递变量 <br>*实例为根据所传递参数自动读取图片,让静态网页实现单页面显示不同内容及分野功能 <br>*以下为 参数分析 <br>* imgMax //图片的总个数 <br>* imgName //起始图片的文件名,所有图片都为jpg图片,传递参数时,只传文件名,例:101 <br>* //图片的读取方式为 +1 ,所以,应该注意 01+1=2 ,而不等于 02 <br>* imgUrl //图片的路径 <br>* pageMax //单页最大显示图片数 <br>*/ <br></font><font color="#007700">function </font><font color="#0000bb">showImg</font><font color="#007700">(</font><font color="#0000bb">imgMax</font><font color="#007700">,</font><font color="#0000bb">imgName</font><font color="#007700">,</font><font color="#0000bb">imgUrl</font><font color="#007700">,</font><font color="#0000bb">pageMax</font><font color="#007700">) { <br> </font><font color="#0000bb">imgName </font><font color="#007700">= eval(</font><font color="#0000bb">imgName</font><font color="#007700">); <br> </font><font color="#0000bb">pageMax </font><font color="#007700">= eval(</font><font color="#0000bb">pageMax</font><font color="#007700">); <br> </font><font color="#0000bb">imgMax </font><font color="#007700">= eval(</font><font color="#0000bb">imgMax</font><font color="#007700">); <br> var </font><font color="#0000bb">pageUrl</font><font color="#007700">=</font><font color="#dd0000">""</font><font color="#007700">; <br> </font><font color="#0000bb">pageUrl </font><font color="#007700">= </font><font color="#0000bb">window</font><font color="#007700">.</font><font color="#0000bb">location</font><font color="#007700">; <br> </font><font color="#0000bb">pageUrl </font><font color="#007700">= </font><font color="#0000bb">pageUrl</font><font color="#007700">.</font><font color="#0000bb">toString</font><font color="#007700">() </font><font color="#ff8000">//获取当前页的URL,并附给字符串 pageUrl <br> </font><font color="#007700">var </font><font color="#0000bb">Parameter </font><font color="#007700">= </font><font color="#0000bb">pageUrl</font><font color="#007700">.</font><font color="#0000bb">split</font><font color="#007700">(</font><font color="#dd0000">"?"</font><font color="#007700">); </font><font color="#ff8000">//以 ? 为分隔符,将上面获得的 URL 拆分成数组 <br> </font><font color="#0000bb">Url </font><font color="#007700">= </font><font color="#0000bb">Parameter</font><font color="#007700">[</font><font color="#0000bb">0</font><font color="#007700">]+</font><font color="#dd0000">"?page"</font><font color="#007700">; </font><font color="#ff8000">//取得去掉参数后的URL,备后面翻页使用 <br> </font><font color="#0000bb">Parameter </font><font color="#007700">= </font><font color="#0000bb">Parameter</font><font color="#007700">[</font><font color="#0000bb">1</font><font color="#007700">]; </font><font color="#ff8000">//取得 ? 的后一部分 <br> </font><font color="#007700">var </font><font color="#0000bb">Parameter </font><font color="#007700">= </font><font color="#0000bb">pageUrl</font><font color="#007700">.</font><font color="#0000bb">split</font><font color="#007700">(</font><font color="#dd0000">"="</font><font color="#007700">); </font><font color="#ff8000">//在次以 = 拆分 <br> </font><font color="#0000bb">Parameter </font><font color="#007700">= </font><font color="#0000bb">Parameter</font><font color="#007700">[</font><font color="#0000bb">1</font><font color="#007700">]; </font><font color="#ff8000">//取得参数 <br> </font><font color="#007700">if(</font><font color="#0000bb">Parameter</font><font color="#007700"><font color="#0000bb">0</font><font color="#007700">||</font><font color="#0000bb">Parameter</font><font color="#007700">==</font><font color="#dd0000">""</font><font color="#007700">||</font><font color="#0000bb">isNaN</font><font color="#007700">(</font><font color="#0000bb">Parameter</font><font color="#007700">)) { <br> </font><font color="#0000bb">Para</font><font color="#007700">=</font><font color="#0000bb">1</font><font color="#007700">; <br> } <br> else { <br> </font><font color="#0000bb">Para</font><font color="#007700">=</font><font color="#0000bb">Parameter</font><font color="#007700">; <br> } </font><font color="#ff8000">//如果参数未设置或错误设置,则自动为1,否则为设置数 <br> </font><font color="#0000bb">img </font><font color="#007700">= new Array(); </font><font color="#ff8000">//设置图片组变量 <br> </font><font color="#007700">for(</font><font color="#0000bb">i</font><font color="#007700">=</font><font color="#0000bb">0</font><font color="#007700">;</font><font color="#0000bb">i</font><font color="#007700"><font color="#0000bb">imgMax</font><font color="#007700">;</font><font color="#0000bb">i</font><font color="#007700">++){ <br> </font><font color="#0000bb">img</font><font color="#007700">[</font><font color="#0000bb">i</font><font color="#007700">] = </font><font color="#0000bb">imgName</font><font color="#007700">+</font><font color="#0000bb">i</font><font color="#007700">; <br> } </font><font color="#ff8000">//给组中的每一个变量附值 <br> </font><font color="#0000bb">start </font><font color="#007700">= (</font><font color="#0000bb">Para </font><font color="#007700">- </font><font color="#0000bb">1</font><font color="#007700">)*</font><font color="#0000bb">pageMax</font><font color="#007700">; </font><font color="#ff8000">//每页中开始的图片名称 <br> </font><font color="#0000bb">end </font><font color="#007700">= ((</font><font color="#0000bb">start</font><font color="#007700">+</font><font color="#0000bb">pageMax</font><font color="#007700">)>=</font><font color="#0000bb">img</font><font color="#007700">.</font><font color="#0000bb">length</font><font color="#007700">)?</font><font color="#0000bb">img</font><font color="#007700">.</font><font color="#0000bb">length</font><font color="#007700"><font color="#0000bb">img src</font><font color="#007700">=</font><font color="#dd0000">"images/smilies/frown.gif" </font><font color="#0000bb">border</font><font color="#007700">=</font><font color="#dd0000">"0" </font><font color="#0000bb">alt</font><font color="#007700">=</font><font color="#dd0000">""</font><font color="#007700">></font><font color="#0000bb">start</font><font color="#007700">+</font><font color="#0000bb">pageMax</font><font color="#007700">); </font><font color="#ff8000">//结束的图片名称 <br> </font><font color="#0000bb">document</font><font color="#007700">.</font><font color="#0000bb">write</font><font color="#007700">(</font><font color="#dd0000">"<table border="0" width="100%" align="center">"<font color="#007700">) </font><font color="#ff8000">//制表 <br> </font><font color="#007700">for(</font><font color="#0000bb">i</font><font color="#007700">=</font><font color="#0000bb">start</font><font color="#007700">;</font><font color="#0000bb">i</font><font color="#007700"><font color="#0000bb">end</font><font color="#007700">;</font><font color="#0000bb">i</font><font color="#007700">++) { <br> </font><font color="#0000bb">document</font><font color="#007700">.</font><font color="#0000bb">write </font><font color="#007700">(</font><font color="#dd0000">"<tr align="center"><td> <img src="</font><font%20color=" alt="HTML 网页 间利用 JavaScript 通过 URL 传递变量_PHP" >+<font color="#0000bb">imgUrl</font><font color="#007700">+</font><font color="#dd0000">""</font><font color="#007700">+</font><font color="#0000bb">img</font><font color="#007700">[</font><font color="#0000bb">i</font><font color="#007700">]+</font><font color="#dd0000">".jpg><br></font> </td></tr>"</font><font color="#007700">); <br> } </font><font color="#ff8000">//输出相应图片 <br> </font><font color="#0000bb">document</font><font color="#007700">.</font><font color="#0000bb">write </font><font color="#007700">(</font><font color="#dd0000">"<tr align="center"><td>"<font color="#007700">) </font><font color="#ff8000">//制表 <br> </font><font color="#007700">if(</font><font color="#0000bb">start</font><font color="#007700">!=</font><font color="#0000bb">0</font><font color="#007700">) { <br> </font><font color="#0000bb">pre </font><font color="#007700">= </font><font color="#0000bb">Url</font><font color="#007700">+</font><font color="#dd0000">"="</font><font color="#007700">+eval(</font><font color="#0000bb">Para</font><font color="#007700">-</font><font color="#0000bb">1</font><font color="#007700">); <br> </font><font color="#0000bb">document</font><font color="#007700">.</font><font color="#0000bb">write</font><font color="#007700">(</font><font color="#dd0000">"<a href="</font><font%20color=">+</a></font><font color="#0000bb">pre</font><font color="#007700">+</font><font color="#dd0000">">上一页"</font><font color="#007700">); <br> } else { <br> </font><font color="#0000bb">document</font><font color="#007700">.</font><font color="#0000bb">write</font><font color="#007700">(</font><font color="#dd0000">"上一页"</font><font color="#007700">); <br> } <br> </font><font color="#0000bb">document</font><font color="#007700">.</font><font color="#0000bb">write</font><font color="#007700">(</font><font color="#dd0000">" "</font><font color="#007700">) <br> if(</font><font color="#0000bb">end</font><font color="#007700"><font color="#0000bb">img</font><font color="#007700">.</font><font color="#0000bb">length</font><font color="#007700">) { <br> </font><font color="#0000bb">Para </font><font color="#007700">= eval(</font><font color="#0000bb">Para</font><font color="#007700">)+</font><font color="#0000bb">1</font><font color="#007700">; <br> </font><font color="#0000bb">next </font><font color="#007700">= </font><font color="#0000bb">Url</font><font color="#007700">+</font><font color="#dd0000">"="</font><font color="#007700">+</font><font color="#0000bb">Para</font><font color="#007700">; <br> </font><font color="#0000bb">document</font><font color="#007700">.</font><font color="#0000bb">write</font><font color="#007700">(</font><font color="#dd0000">"<a href="</font><font%20color=">+</a></font><font color="#0000bb">next</font><font color="#007700">+</font><font color="#dd0000">">下一页"</font><font color="#007700">); <br> } else { <br> </font><font color="#0000bb">document</font><font color="#007700">.</font><font color="#0000bb">write</font><font color="#007700">(</font><font color="#dd0000">"下一页"</font><font color="#007700">); <br> } </font><font color="#ff8000">//分析上下页连接 <br> </font><font color="#0000bb">document</font><font color="#007700">.</font><font color="#0000bb">write</font><font color="#007700">(</font><font color="#dd0000">"</font></font> </td></tr></font></font> </table>"</font><font color="#007700">); </font><font color="#ff8000">//制表 <br> </font><font color="#007700">} <br> <br> </font><font color="#0000bb">imgMax</font><font color="#007700">=</font><font color="#dd0000">"5"</font><font color="#007700">; <br> </font><font color="#0000bb">imgName</font><font color="#007700">=</font><font color="#dd0000">"101"</font><font color="#007700">; <br> </font><font color="#0000bb">imgUrl</font><font color="#007700">=</font><font color="#dd0000">"./"</font><font color="#007700">; <br> </font><font color="#0000bb">pageMax</font><font color="#007700">=</font><font color="#dd0000">"2"</font><font color="#007700">; <br> <br> <br> <br> </font><font color="#0000bb">showImg</font><font color="#007700">(</font><font color="#0000bb">imgMax</font><font color="#007700">,</font><font color="#0000bb">imgName</font><font color="#007700">,</font><font color="#0000bb">imgUrl</font><font color="#007700">,</font><font color="#0000bb">pageMax</font><font color="#007700">); <br></font><font color="#0000bb"><br></font></font> </font></font></font></font></code><hr>

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



How to send web pages to the desktop as a shortcut in Edge browser? Many of our users want to display frequently used web pages on the desktop as shortcuts for the convenience of directly opening access pages, but they don’t know how to do it. In response to this problem, the editor of this issue will share the solution with the majority of users. , let’s take a look at the content shared in today’s software tutorial. The shortcut method of sending web pages to the desktop in Edge browser: 1. Open the software and click the "..." button on the page. 2. Select "Install this site as an application" in "Application" from the drop-down menu option. 3. Finally, click it in the pop-up window

With the continuous development of social media, Xiaohongshu has become a platform for more and more young people to share their lives and discover beautiful things. Many users are troubled by auto-save issues when posting images. So, how to solve this problem? 1. How to solve the problem of automatically saving pictures when publishing on Xiaohongshu? 1. Clear the cache First, we can try to clear the cache data of Xiaohongshu. The steps are as follows: (1) Open Xiaohongshu and click the "My" button in the lower right corner; (2) On the personal center page, find "Settings" and click it; (3) Scroll down and find the "Clear Cache" option. Click OK. After clearing the cache, re-enter Xiaohongshu and try to post pictures to see if the automatic saving problem is solved. 2. Update the Xiaohongshu version to ensure that your Xiaohongshu

With the popularity of Douyin short videos, user interactions in the comment area have become more colorful. Some users wish to share images in comments to better express their opinions or emotions. So, how to post pictures in TikTok comments? This article will answer this question in detail and provide you with some related tips and precautions. 1. How to post pictures in Douyin comments? 1. Open Douyin: First, you need to open Douyin APP and log in to your account. 2. Find the comment area: When browsing or posting a short video, find the place where you want to comment and click the "Comment" button. 3. Enter your comment content: Enter your comment content in the comment area. 4. Choose to send a picture: In the interface for entering comment content, you will see a "picture" button or a "+" button, click

Apple's recent iPhones capture memories with crisp detail, saturation and brightness. But sometimes, you may encounter some issues that may cause the image to look less clear. While autofocus on iPhone cameras has come a long way, allowing you to take photos quickly, the camera can mistakenly focus on the wrong subject in certain situations, making the photo blurry in unwanted areas. If your photos on your iPhone look out of focus or lack sharpness overall, the following post should help you make them sharper. How to Make Pictures Clearer on iPhone [6 Methods] You can try using the native Photos app to clean up your photos. If you want more features and options

In PowerPoint, it is a common technique to display pictures one by one, which can be achieved by setting animation effects. This guide details the steps to implement this technique, including basic setup, image insertion, adding animation, and adjusting animation order and timing. Additionally, advanced settings and adjustments are provided, such as using triggers, adjusting animation speed and order, and previewing animation effects. By following these steps and tips, users can easily set up pictures to appear one after another in PowerPoint, thereby enhancing the visual impact of the presentation and grabbing the attention of the audience.

Are you also using Foxit PDF Reader software? So do you know how Foxit PDF Reader converts pdf documents into jpg images? The following article brings you how Foxit PDF Reader converts pdf documents into jpg images. For those who are interested in the method of converting jpg images, please come and take a look below. First start Foxit PDF Reader, then find "Features" on the top toolbar, and then select the "PDF to Others" function. Next, open a web page called "Foxit PDF Online Conversion". Click the "Login" button on the upper right side of the page to log in, and then turn on the "PDF to Image" function. Then click the upload button and add the pdf file you want to convert into an image. After adding it, click "Start Conversion"

The browser cannot open the web page but the network is normal. There are many possible reasons. When this problem occurs, we need to investigate step by step to determine the specific cause and solve the problem. First, determine whether the webpage cannot be opened is limited to a specific browser or whether all browsers cannot open the webpage. If only one browser cannot open the web page, you can try to use other browsers, such as Google Chrome, Firefox, etc., for testing. If other browsers are able to open the page correctly, the problem is most likely with that specific browser, possibly

When using WPS office software, we found that not only one form is used, tables and pictures can be added to the text, pictures can also be added to the table, etc. These are all used together to make the content of the entire document look richer. , if you need to insert two pictures into the document and they need to be arranged side by side. Our next course can solve this problem: how to place two pictures side by side in a wps document. 1. First, you need to open the WPS software and find the picture you want to adjust. Left-click the picture and a menu bar will pop up, select "Page Layout". 2. Select "Tight wrapping" in text wrapping. 3. After all the pictures you need are confirmed to be set to "Tight text wrapping", you can drag the pictures to the appropriate position and click on the first picture.
