javascript-有没有一种方法可以用php获取这些值?
我有一个JS代码,它使用javascript-有没有一种方法可以用php获取这些值?,php,javascript,jquery,Php,Javascript,Jquery,我有一个JS代码,它使用onclick方法工作,并在一个新窗口中打开一个图像,该窗口的大小与图像的大小相同 我改编自BolGallery的剧本。但是bolGallery脚本在PHP中对此进行解析,并且能够动态地获取“title”、“width”和“height”值。以及“ImageFile”值 我的问题是,有没有一种方法可以通过php实现这些功能 我对JS不是很了解 function GalleryPopup(imageFile, width, height, title){ var
onclick
方法工作,并在一个新窗口中打开一个图像,该窗口的大小与图像的大小相同
我改编自BolGallery的剧本。但是bolGallery脚本在PHP中对此进行解析,并且能够动态地获取“title”、“width”和“height”值。以及“ImageFile”值
我的问题是,有没有一种方法可以通过php实现这些功能
我对JS不是很了解
function GalleryPopup(imageFile, width, height, title){
var html = '<title>' + title + ' - Click to close </title><body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 onclick=\"javascript:window.close()\"><img src=\"' + imageFile + '\" alt=\"Click to close\"></body>';
var popup = window.open(imageFile, '_blank', 'width=' + width+ ', height=' + height + ', status=no');
popup.document.write(html);
popup.focus();
}
这样行吗
我还有jQuery..在jQuery中,您可以通过以下方式获得图像的大小:
$('img').width();
$('img').height();
//这用于获取源文件和标题:
$('img').attr('src');
$('img').attr('title');
标题存储在哪里?数据库、文本文件还是什么?有一种方法可以使用
新图像
在JavaScript中加载文件并等待加载,然后您可以只检查其宽度
和高度
属性,但根据我的经验,它非常脆弱。哦,见鬼。我不知道标题为的全尺寸图片已经在页面上了。我以为你在点击缩略图什么的。我明白了,所以:var-imageHeight=$('img').height()代码>?您希望PHP为您实现什么?您想让它生成新打开页面的代码吗?
$('img').attr('src');
$('img').attr('title');