1. جافا سكريبت
نسخة الكود كما يلي:
/**
* احصل على مرجع طلب HTTP
* ishost ما إذا كان يجب إعادة المضيف عندما يكون المرجع المنطقي فارغًا (عنوان الصفحة الرئيسية)
*/
وظيفة get_http_referer (Ishost) {
if (iShost === undefined) {iShost = true ؛ }
if (document.referrer) {
Return document.referrer ؛
} آخر {
إذا (Ishost) {
إرجاع window.location.protocol + "//" + window.location.host ؛
} آخر {
يعود ""؛
}
}
}
2. ج#
نسخة الكود كما يلي:
/// <summary>
/// احصل على مرجع طلب HTTP
/// </summary>
/// <param name = "iShost"> ما إذا كان يجب إرجاع المضيف عندما يكون المرجع فارغًا (عنوان الصفحة الرئيسية) </param>
/// <returns> String </roprings>
السلسلة العامة getReferer (Bool Ishost)
{
if (request.urlreferrer! = null)
{
Return request.urlreferrer.toString () ؛
}
آخر
{
إذا (Ishost)
{
Return request.url.scheme + ": //" + request.url.Authority ؛
}
آخر
{
يعود ""؛
}
}
}
3. احصل على أجزاء مختلفة من عنوان URL للطلب في C#
موقع الويب: http: // localhost: 1897/news/press/content.aspx/123؟ id = 1#toc
نسخة الكود كما يلي:
request.ApplicationPath/
request.physicalpathd: /projects/solution/web/news/press/content.aspx
system.io.path.getDirectoryName (request.physicalpath) d:/projects/solution/web/news/press
request.physicalapplicationPathd:/مشاريع/حل/ويب/
System.io.path.getFilename (request.physicalpath) content.aspx
request.currentExecutionFilePath/news/press/content.aspx
request.filepath/news/press/content.aspx
request.path/news/press/content.aspx/123
request.Rawurl/News/Press/Content.aspx/123؟ id = 1
request.url.absolutepath/news/press/content.aspx/123
request.url.absoluteurihttp: // localhost: 1897/news/press/content.aspx/123؟ id = 1
request.url.schemehttp
request.url.hostlocalhost
request.url.port1897
request.url.AuthorityLocalhost: 1897
request.url.localpath/news/press/content.aspx/123
request.pathinfo/123
request.url.pathandquery/news/press/content.aspx/123؟ id = 1
request.url.query؟ id = 1
request.url.fragment
request.url.segments/
أخبار/
يضعط/
content.aspx/
123
4. كائن JavaScript.
//www.vevb.com/article/57407.htm
ماذا عن ذلك؟ هل تعلمت الحصول على مرجع الصفحة في JavaScript و C#؟ إذا كان لديك أي أسئلة ، يرجى الاتصال بي.