導航:首頁 > 編程語言 > js中打開圖片

js中打開圖片

發布時間:2023-02-21 07:02:00

❶ 怎麼讓js 里的圖片鏈接成為在新窗口打開

$('mainphofo').onclick = function() {location = this.getAttribute('name');}
改成
$('mainphofo').onclick = function() {window.open(this.getAttribute('name'));}

javascript打開新窗口顯示圖片,怎麼用js文件實現

其實很簡單,就像xiangyuecn回答的那樣。不過那是開新的瀏覽器窗口顯示圖片,如果你要在同一個窗口顯示,那就要用到JS。

❸ JS圖片新窗口打開

<a href='' target='_blank'></a>
在a標簽中添加target='_blank'屬性

❹ javascript打開新窗口顯示圖片,怎麼用js文件實現

window.open(surl,
sname);
surl
是一個字元串,它指定了要顯示文檔的url。如果不指定url,就產生一個空窗口。
sname
是定義的窗口名字,這個名字被用於<form>或者<a>標記的
target
屬性。在internet
explorer
5
和以後版本,如果定義這個數值為
"_search",那麼就將在瀏覽器的搜索區打開
surl

❺ javascript:點擊圖片打開新窗口瀏覽圖片

方法一:
<style>
img{
width:50%;
height:50%
}
</style>
<img src=1.PNG onclick="lookimg(this.src)">
<script>
function lookimg(str)
{
var newwin=window.open()
newwin.document.write("<img src="+str+" />")
}
</script>

方法二版權:
<img src=1.png onclick="lookimg(this.src)">
<script>
function lookimg(str)
{
var newwin=window.open()
myimg=newwin.document.createElement("img")
myimg.src=str
newwin.document.body.appendChild(myimg)
}
</script>

❻ js彈出圖片怎麼寫網頁一打開就彈出一張照片的那種!

沒明白你的意思。我寫的你看看能用就採用

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> </title>
</head>
<style>
.img{
position: fixed;
z-index: 10;
top:50%;
left: 50%;
margin-top: -200px;
margin-left: -200px;
}
#close{
position: absolute;
left: 10px;
top: 5px;

}
body{
background-color: #333;
}
</style>

<body>
<div class="mask"></div>
<div class="img">
<span id="close">關閉</span>
<img src="dd.png" alt="">
</div>
</body>
<script>
var mask = document.getElementById('close');
var img = document.getElementsByTagName('img')[0];
mask.onclick=function(){
img.style.display = "none";
this.style.display = "none";
}
</script>
</html>

沒明白你的意思。我想的是打開頁面的時候就是一個彈窗狀態,當我點擊關閉後彈窗圖片消失。我中間的白色「找不到伺服器」是圖片

❼ 用JS在新窗口打開本圖片

<img src="圖片連接" width="400" height="400" onclick="op(this.src)" />
<script language="javascript">
function op(c_url)
{
window.open(c_url)
}
</script>

❽ js 圖片新窗口打開自動適應大小

你這樣做是不行的,因為你彈出窗口url直接是個圖片的地址,因此彈出窗口沒有body對象,這樣內就無法容通過腳本來進行控制。

可行的辦法是將你的圖片寫入到一個臨時的a.htm中,這樣在a.htm中就可以非常方便的設置窗口邊距了。

<body margin=0 padding=0>

❾ 需要一個js腳本,實現打開圖片功能

最好不要使用替換的方式
使用JS 點擊打開方式會比較好

imglist=document.getElementsByTagName("IMG")
for(var i=0;i<imglist.length;i++){
o=imglist[i]
o.onclick=window.open(this.src);
o.style.cursor="pointer";
}
/*
javascript:document.getElementsByTagName("IMG")[0].getAttribute("src")

*/

❿ 如何用JS語句顯示圖片

需要准備的材料分別有:電腦、html編輯器、瀏覽器。

1、首先,打開html編輯器專,新建html文件,例如:index.html。

閱讀全文

與js中打開圖片相關的資料

熱點內容
安卓60lbe安全大師 瀏覽:90
湖北省事業單位領導配置文件 瀏覽:608
app倒計時任務視頻怎麼跳過 瀏覽:531
建設監理投標文件應注意哪些事情 瀏覽:660
電商有效網站是指什麼 瀏覽:805
如何導入新的數據源 瀏覽:622
探月少兒編程如何禁止旋轉 瀏覽:524
數據運營模板是什麼意思 瀏覽:440
win10fax程序下載 瀏覽:527
找同款app有哪些 瀏覽:147
linux讀取文件整個過程 瀏覽:577
百信集團的網站叫什麼名字 瀏覽:67
開發解壓app理念是什麼 瀏覽:128
linux源代碼路徑 瀏覽:854
美圖2root後不能升級了 瀏覽:133
shell文件size 瀏覽:350
通過大數據查幹部哪些內容 瀏覽:78
如何編程輸出一個數的十位數 瀏覽:760
9月7日蘋果發布會 瀏覽:150
u盤里文件打開都是亂碼怎麼辦 瀏覽:402

友情鏈接