使用document.write在PHP中编写JS

This is failing but i dont know how to make it work.

I have a php array:

$swipe_list = array('customers.html', 'index.html', 'atr_backplane.html');

This is to know which pages have carousels and need touch support.

so i check the page in php and if its listed the JS will check its a touch device and write the addional js mobile file.

is it because the server script trys ti run before the js can detect at the client side??

<?php
if(in_array($selected, $swipe_list)){ ?>
<script type="text/javascript">

function isTouchDevice(){ document.write('<script type="text/javascript" src="js/jquery.mobile.custom.min.js"></script>')
}

</script>            
<?php }?>
<?php if(!in_array($selected, $exclude_list)){       
print '<script type="text/javascript" src="js/camera.js"></script>';
}
?>
查看全部
dpcwz210393
dpcwz210393
2013/07/04 15:33
  • php
  • javascript
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

3个回复