0

I need to do the following:

When access mysite.com check if another page X contain div id "intro", if so, redirect mysite.com to mysite.com/search. If page x does not contain div id, load mysite.com.

I tried this:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script type="text/javascript">
jQuery(function($){
$('#result').load('Page2.html #intro');
});
</script>

page with div id :

<div id="intro" style="display: none">My sample content</div>
4

1 回答 1

0

就是这个 ?

 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js">    </script>
 <script type="text/javascript">
 jQuery(function($)
 if ($('#result').load('page2.html #divID').length === 0){
 window.location.href = "redirect.html";
 }
 </script>
于 2013-03-13T20:01:30.920 回答