启动页面加载而不是链接

时间:2019-12-12 13:15:24

标签: javascript jquery

单击时,以下内容会在页面上显示一个框。

        public void SetProperty(PropertyInfo property, string value)
    {
        //Get the type we need to cast to.
        Enum.TryParse(property.PropertyType.Name, true, out TypeCode enumValue); //Get the type based on typecode
        //Cast to that type
        var convertedValue = Convert.ChangeType(value, enumValue); //Convert the value to that of the typecode
        //Assign
        property.SetValue(this, convertedValue); // Set the converted value

如果URL为www.domain.com/id=box4,如何在使用javascript或jQuery加载页面时显示此框?

谢谢。

3 个答案:

答案 0 :(得分:0)

使用javascript:

var button = document.querySelector('.launcher-var a'),
    yourLink = 'www.domain.com/id=box4?';

document.addEventListener('DOMContentLoaded', function(){
 if(window.location.href == yourLink ){
  button.click();
 }
});

评论后的答案: 如果URL在页面加载时具有id = box4,则不是URL-6分钟前John Higgins

解决方案:

var button = document.querySelector('.launcher-var a');

document.addEventListener('DOMContentLoaded', function(){
 if(window.location.href.indexOf("id=box4") > -1 ){
  button.click();
 }
});

答案 1 :(得分:-1)

$(document).ready(function(){
 if(window.location.href == "www.domain.com/id=box4"){ 
 //open box here
 }
)};

答案 2 :(得分:-1)

我使用以下方法使之工作。

$(document).ready(function() { 
    if(window.location.href.indexOf('?id=') > 0){ 
       $(".launcher-var").click();
    }
});