アプリ版:「スタンプのみでお礼する」機能のリリースについて

最近JavaScriptを始めた者です。
ポップアップをアドレスバーとステータスバーを非表示にした状態で中央に表示させたいのですが、以下のコードでは、リンクをクリックしても反応がありません。

function openWinCenter(url,id,w,h,scrollFlag) {

x = (screen.width - w) / 2;
y = (screen.height - h) / 2;

if(scrollFlag){

if(navigator.appName== "Microsoft Internet Explorer"){

w=w+16;

}

window.open(url,id,"screenX="+x+",screenY="+y+",left="+x+",top="+y+",width"+w+",height="+h+",scrollbars=yes,location=no,status=no");

}else{

window.open(url,id,"screenX="+x+",screenY="+y+",left="+x+",top="+y+",width="+w+",height="+h+",scrollbars=no,location=no,status=no");

}

}

どこを修正したらいいのか教えてください、よろしくお願いします。

A 回答 (1件)

以下のコードでウインドウが開きました。


スクリプト部分は一箇所を除き修正してないので
その他の部分がおかしくなってませんか?

<html>
<head>
<title>center</title>
<script type="text/javascript">
<!--
function openWinCenter(url,id,w,h,scrollFlag) {

x = (screen.width - w) / 2;
y = (screen.height - h) / 2;

if(scrollFlag){

if(navigator.appName== "Microsoft Internet Explorer"){

w=w+16;

}

window.open(url,id,"screenX="+x+",screenY="+y+",left="+x+",top="+y+",width="+w+",height="+h+",scrollbars=yes,location=no,status=no");

}else{

window.open(url,id,"screenX="+x+",screenY="+y+",left="+x+",top="+y+",width="+w+",height="+h+",scrollbars=no,location=no,status=no");

}

}
-->
</script>
</head>
<body>
<a href="#" onclick="openWinCenter('test.html','test',100,100,true);">link</a>
</body>
</html>

考えられるとすれば・・・
1.<script>タグが正しく閉じられていない
2.関数の呼び出し名が間違っている
3.イベントのくくりとパラメータのくくりに同じ文字を使っている。
→onclick="openWinCenter("test.html","test",100,100,true);"
などでしょうか。
ご確認ください。

ちなみに一箇所修正というのは上のほうのwindow.openのパラメータで
「width"+w+",」と、「=」が抜けているところです。
    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!