jQuery / Javascript - 从电子邮件链接弹出一个特定的弹出窗口

时间:2013-12-12 19:30:39

标签: javascript jquery html

所以我想要实现的是这个

用户将收到一封包含链接的电子邮件

http://sitess.com/someother_stuff

一旦他们从电子邮件中点击该链接,就会将他们带到有链接的网站的主页...当您点击该链接时会出现一个弹出窗口

但我希望一旦用户点击电子邮件上的链接并将其带到网站,就会触发弹出窗口。

这是我正在处理的链接的片段

<div id="sidebar-active-searches" style="padding: 5px 20px; line-height: 120%; height: 660px;">
  <a class="thickbox" title="JEWISH FEDERATION OF GREATER LOS ANGELES – VP of STRATEGIC PHILANTHROPY" href="/active-searches-items/jewish-federation-of-greater-los-angeles-vp-of-strategic-philanthropy/?TB_iframe">
  <strong>Jewish Federation of <br />Greater Los Angeles</strong> 
  <img class="alignnone size-full wp-image-556" alt="&gt;&gt;"  src="http://www.moppenheim.com/wp-content/uploads/red-arrow.gif" width="9" height="7" />
  <br /> 
    Vice President of Strategic Philanthropy
  </a>
</div> 

之前我有类似的东西,但它不起作用

<script type='text/javascript'>
  $(document).ready(function() {
  // find hash from parent. if it exists, trigger a click on one of the items above. 
  // the hash must match the id of the item.
  var hash = parent.window.location.hash;

  // split the query string apart from the hash  - this expect the hash to be first!
  var hash_array = hash.split("&");

  // make sure the first array element starts with a '#' mark, otherwise, it is probably   just the query string.  
  if(hash_array[0].indexOf('#')>=0)
    {
      $(hash_array[0]).trigger('click');
    }
 });
</script>

1 个答案:

答案 0 :(得分:1)

在您的超链接中

http://sitess.com/someother_stuff?LinkToPopup=ExampleLinkID

在您的主页(检测是否有传递的项目:

// Read a page's GET URL variables and return them as an associative array.
function getUrlVars() {
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for (var i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}

var urlPassedParameters = getUrlVars();

if (urlPassedParameters['LinkToPopup'] != null) {
            var linkToPopup = decodeURI(urlPassedParameters['LinkToPopup']);
            $(linkToPopup).click()
        }