Forum Moderators: phranque
Interesting problem I've got...
I want to create an Internet Shortcut link that users can download and put on their desktop.
The link needs to open a window which has a fixed size, no scrollbars, no status bar, not resizeable etc - rather like a popup window. It mustn't open a normal window first.
I think it might be do-able with some Javascript, becuase I vaguely remember having such a link which opened multiple windows with one click (something to do with giving to multiple charity sites, I think).
I've been struggling with this one over the past few days, but I haven't got anywhere with it.
Any ideas? Help would be very much appreciated.
D.
i.e. the shortcut points to the landing page, landing page fires a popup with the correct specs, and then itself closes onBlur or something so the customer is left with only the popup.
It would be cool if you can find a way to do it right off the shortcut, but I doubt it exists since you can't run javascript outside of the browser.
should do what you want...it may seem long, but it's a way to get around the dialog box that opens asking you to close the page if you try the simple window.close()
##########page to open first#########
<html>
<head>
<title>1.htm - opener</title>
<script language="JavaScript" type="text/JavaScript">
<!--
function openWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>
</head>
<body onLoad="openWindow('2.htm?yup=1','','width=300,height=300')">
</body>
</html>
#### basic code for the popup page (2.htm) ######
<html>
<head>
<title>1</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function closeParent(){
try{
var q = queryString("yup");
if( q=="1" ){
var op = window.opener;
op.opener = self;
op.close();
}
}
catch(er)
{}
}
function PageQuery(q) {
if(q.length > 1) this.q = q.substring(1, q.length);
else this.q = null;
this.keyValuePairs = new Array();
if(q) {
for(var i=0; i < this.q.split("&").length; i++) {
this.keyValuePairs[i] = this.q.split("&")[i];
}
}
this.getKeyValuePairs = function() { return this.keyValuePairs; }
this.getValue = function(s) {
for(var j=0; j < this.keyValuePairs.length; j++) {
if(this.keyValuePairs[j].split("=")[0] == s)
return this.keyValuePairs[j].split("=")[1];
}
return false;
}
this.getParameters = function() {
var a = new Array(this.getLength());
for(var j=0; j < this.keyValuePairs.length; j++) {
a[j] = this.keyValuePairs[j].split("=")[0];
}
return a;
}
this.getLength = function() { return this.keyValuePairs.length; }
}
function queryString(key){
var page = new PageQuery(window.location.search);
return unescape(page.getValue(key));
}
//-->
</script>
</head>
<body onLoad="closeParent()">
</body>
</html>
I tried out your solution. At first it worked well as a shortcut from the desktop, but after a couple of goes, it crashed my browser (IE6)!
I finally got someone to program a small executable, which does the trick nicely. It also means that the user will have a special icon on the desktop.
But someone else came up with another direct HTML solution, which works neatly. You might be interested in this solution:
<HTML>
<HEAD>
<TITLE> TEST DOC </TITLE>
</HEAD>
<BODY>
<script language="JavaScript">
<!--
top.window.moveTo(3000,30000);
top.window.resizeTo(1,1); open('http://www.mysite.com/file.html','blwy','width=160,height=230,scrollbars=no,menubar=no,directories=no,status=no,titlebar=no');window.opener=''; window.close();
--></script>
</BODY>
</HTML>
Thanks, anyway, for your help.
D.