⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 viewer.js

📁 关于网上汽车销售系统的详细编程项目实战实例
💻 JS
字号:
/**
 * viewer.js
 *
 * @author  Actuate Corporation
 * @version 1.0
 */

function replaceDuplicateParams(sURL, sRegExp, sValue)
{
	var pattern = sRegExp + "=\[A-Za-z0-9_%]*&?";
	var regExp = new RegExp( pattern, "i");
	//alert("replaceDuplicateParams sURL= "+sURL+" regExp= "+regExp); 
	var resultArray = regExp.exec(sURL);
	var listArray = sURL.split(regExp);
	var sRetURL = null;
	
	// Check if the parameter is already existing in the url
	if( resultArray != null)
	{
		//Check if more than one occurances are found in the url for the given parameter
		if( resultArray.length == 1)
		{
			// Replace the value of the parameter with the new value
			
			if( listArray.length == 1 || listArray[1] == "")
			{
				//sRetURL = listArray[0] + sRegExp + sValue;
				sRetURL = sURL.replace(regExp, sRegExp +"="+ sValue);
			}
			else
			{
				sRetURL = sURL.replace(regExp, sRegExp + "="+ sValue + "&");
				
			}
			
			// End of replace the value of the parameter with the new value
		}
		else
		{
		}
	}
	else
	{
		sRetURL = sURL + "&" + sRegExp + "="+ sValue;
	}
	return sRetURL;
}

/**
 *
 */
function removeParams(sObjURL, sParam)
{
	var pattern = sParam + "=[^&]*&?";
	var regExp = new RegExp( pattern, "i");
	var resultArray = regExp.exec(sObjURL);
	var listArray = sObjURL.split(regExp);
	var sRetURL = null;

	// Check if the parameter is existing in the url
	if( resultArray != null)
	{
		// Remove the  the parameter 
			if( listArray.length == 1 || listArray[1] == "")
			{
				sRetURL = sObjURL.substring(0 , (listArray[0].length-1));
			}
			else
			{
				sRetURL = sObjURL.replace(regExp, "");
			}
	}
	else
	{
			sRetURL = sObjURL;
	}
	return sRetURL;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -