473,594 Members | 2,756 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

what's wrong with this code?

Hi,

Does anybody know what's wrong with the following code:

<div align="center"> <a href="flashplay .php"
onclick="NewWin dow(this.href,' Listen
this!','280','2 80','no','rando m');return false" onfocus="this.b lur()"
onMouseOut="MM_ swapImgRestore( )"
onMouseOver="MM _swapImage('Ima ge20','','gifs/mp3_1.gif',1)"> <img
src="gifs/mp3.gif" name="Image20" width="125" height="38"
border="0"></a></div>

The intention is this: when someone click on a rollover image, a new window
pop's up displaying the flashplay.php 280x280px page, but for some reason it
doesn't work...If anyone knows a solution, I'd appreciate it a lot.

Dec 9 '05 #1
7 1244
We'd need to see the source code to your "NewWindow" function before
anyone can help. But also 1) are you blocking popups and 2) are you
sure you should even be using popups? Most people I know block them.

Dec 9 '05 #2

<un***********@ gmail.com> wrote in message
news:11******** ************@g1 4g2000cwa.googl egroups.com...
We'd need to see the source code to your "NewWindow" function before
anyone can help. But also 1) are you blocking popups and 2) are you
sure you should even be using popups? Most people I know block them.


Sorry, my bad.

The source code included in the <head> tag is as follows:

<script language="javas cript" type="text/javascript">
<!--
var win=null;
function NewWindow(mypag e,myname,w,h,sc roll,pos){
if(pos=="random "){LeftPosition =(screen.width) ?Math.floor(Mat h.random()*(scr e
en.width-w)):100;TopPosi tion=(screen.he ight)?Math.floo r(Math.random() *((scre
en.height-h)-75)):100;}
if(pos=="center "){LeftPosition =(screen.width) ?(screen.width-w)/2:100;TopPosi
tion=(screen.he ight)?(screen.h eight-h)/2:100;}
else if((pos!="cente r" && pos!="random") ||
pos==null){Left Position=0;TopP osition=20}
settings='width ='+w+',height=' +h+',top='+TopP osition+',left= '+LeftPosition+ '
,scrollbars='+s croll+',locatio n=no,directorie s=no,status=no, menubar=no,tool b
ar=no,resizable =no';
win=window.open (mypage,myname, settings);}
// -->
</script>

Regarding the issues 1) and 2) - no, I'm not blocking pop-ups and 2)I am
sure I want to use popups. Not that I like them, but I have my objective
reasons.
Dec 9 '05 #3
seeker wrote:
The source code included in the <head> tag is as follows:

<script language="javas cript" type="text/javascript">
<!--
var win=null;
function NewWindow(mypag e,myname,w,h,sc roll,pos){
if(pos=="random " {LeftPosition=( screen.width)?M ath.floor(Math. random()*(scre en.width-w)):100;TopPosi tion=(screen.he ight)?Math.floo r(Math.random() *((scre en.height-h)-75)):100;}
if(pos=="center "){LeftPosition =(screen.width) (screen.width-w)/2:100;TopPosi tion=(screen.he ight)?(screen.h eight-h)/2:100;}
else if((pos!="cente r" && pos!="random") ||
pos==null){Left Position=0;TopP osition=20}
settings='width ='+w+',height=' +h+',top='+TopP osition+',left= '+LeftPosition+ ' ,scrollbars='+s croll+',locatio n=no,directorie s=no,status=no, menubar=no,tool b
ar=no,resizable =no';
win=window.open (mypage,myname, settings);}
// -->
</script>


That code is utter nonsense. Do not use it.
PointedEars
Dec 9 '05 #4
On 09/12/2005 14:30, seeker wrote:

[snip]
<script language="javas cript" type="text/javascript">
<!--
The language attribute is deprecated and redundant, and the SGML
comments are unnecessary, too.
var win=null;
function NewWindow(mypag e,myname,w,h,sc roll,pos){
if(pos=="random "){LeftPosition =(screen.width) ?Math.floor(Mat h.random()*(scr e
en.width-w)):100;TopPosi tion=(screen.he ight)?Math.floo r(Math.random() *((scre
en.height-h)-75)):100;}
if(pos=="center "){LeftPosition =(screen.width) ?(screen.width-w)/2:100;TopPosi
tion=(screen.he ight)?(screen.h eight-h)/2:100;}
else if((pos!="cente r" && pos!="random") ||
pos==null){Left Position=0;TopP osition=20}
settings='width ='+w+',height=' +h+',top='+TopP osition+',left= '+LeftPosition+ '
,scrollbars='+s croll+',locatio n=no,directorie s=no,status=no, menubar=no,tool b
ar=no,resizable =no';
win=window.open (mypage,myname, settings);}


The code you have there is horrid. The following is better:

function createChromeles sWindow(uri, name, width,
height, centre)
{
var features = 'resizable,scro llbars',
popup;

if(('function' == typeof window.open)
|| ('object' == typeof window.open))
{
if(!isNaN(width ) && !isNaN(height)) {
features += ',width=' + width + ',height=' + height;

if(centre && ('object' == typeof screen)
&& !isNaN(screen.h eight)
&& !isNaN(screen.w idth))
{
features += ',left=' + ((screen.width - width) / 2)
+ ',top=' + ((screen.height - height) / 2);
}
}
popup = window.open(uri , name, features);
}
return (popup && (window != popup)) ? popup : null;
}

The random placement feature has been removed as it's a stupid idea, and
centring is controlled via an (optional) boolean. Scrollbars and
resizing are enabled as there is /never/ a reason not allow them.
Finally, rather than assigning the reference to the popup to a global
variable, the reference is returned.

[snip]

All that said, it has nothing to do with your problem. That is almost
certainly caused because of the name you tried to give the new window.
The use of 'Listen this!' is a very bad idea. The name should be
restricted to alphanumeric characters only, contain no spaces,
punctuation or other characters, and must begin with a letter. Something
simpler like 'flashplayer' (based on your URI) would be far better.

<a href="flashplay .php" target="flashpl ayer"
onclick="return !createChromele ssWindow(this.h ref,
this.target, 280, 280);"
...>...</a>

Mike

--
Michael Winter
Prefix subject with [News] before replying by e-mail.
Dec 9 '05 #5
Michael Winter wrote:
The code you have there is horrid. The following is better:

function createChromeles sWindow(uri, name, width,
height, centre)
{
var features = 'resizable,scro llbars',
popup;

if(('function' == typeof window.open)
|| ('object' == typeof window.open))
{
[...]
popup = window.open(uri , name, features);
}
return (popup && (window != popup)) ? popup : null;
IMO `window' can only refer to the same object as `popup' if the value of
`name' is the name of the current window. Why would you want to return
`null' then, as if creating the popup failed? It did not really fail,
the location of the target window was replaced with the value of `uri'.
}

The random placement feature has been removed as it's a stupid idea, and
centring is controlled via an (optional) boolean.


I have that boolean in my window.js as well because it was written before
I realized that "center" does not necessarily mean the center of one screen.
(Thanks to kind people in de.comp.lang.ja vascript and here that provided
photos.)

Especially, it has been reported here that IE always returns the values for
the primary display, while Firefox returns the values for the screen the
(left top corner of the) accessing window is located in.

I have the general use of that argument marked as deprecated since then.
PointedEars
Dec 9 '05 #6
On 09/12/2005 17:46, Thomas 'PointedEars' Lahn wrote:
Michael Winter wrote:
[snip]
return (popup && (window != popup)) ? popup : null;


IMO `window' can only refer to the same object as `popup' if the value of
`name' is the name of the current window.


That wasn't something that I had considered.
Why would you want to return `null' then, as if creating the popup failed?


It is one known pop-up blocking technique to return a reference to the
current window, as in:

window.open = function() {
return window;
};

Though I had no intention of trying to detect failure in general
(impossible anyway), I thought it beneficial to cope with some of the
more simple circumstances.

The code should revert to the initial version: the popup variable should
be removed, the return statement (as it currently is) should also be
removed, and the assignment to 'popup' should become a return statement.

[snip]
The random placement feature has been removed as it's a stupid
idea, and centring is controlled via an (optional) boolean.


I have that boolean in my window.js as well because it was written before
I realized that "center" does not necessarily mean the center of one screen.


I realise that, too. However, I let it remain as a 'less stupid' feature
from the original code.

I am of the opinion that the window manager should be left to its job,
and would personally never attempt to centre a pop-up. I'd rarely use a
pop-up, full stop, but that's a different matter. ;)

[snip]

Mike

--
Michael Winter
Prefix subject with [News] before replying by e-mail.
Dec 9 '05 #7
On 2005-12-09, seeker <so*****@somewh ere.com> wrote:
Hi,

Does anybody know what's wrong with the following code:

<div align="center"> <a href="flashplay .php"
onclick="NewWin dow(this.href,' Listen
this!','280','2 80','no','rando m');return false" onfocus="this.b lur()"
onMouseOut="MM_ swapImgRestore( )"
onMouseOver="MM _swapImage('Ima ge20','','gifs/mp3_1.gif',1)"> <img
src="gifs/mp3.gif" name="Image20" width="125" height="38"
border="0"></a></div>

The intention is this: when someone click on a rollover image, a new window
pop's up displaying the flashplay.php 280x280px page, but for some reason it
doesn't work...If anyone knows a solution, I'd appreciate it a lot.


what's the purpose of onfocus="this.b lur()"


--

Bye.
Jasen
Dec 9 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

125
14652
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from software giant such as Microsoft SQL Server, Oracle, and Sybase? Is PostgreSQL reliable enough to be used for high-end commercial application? Thanks
72
5797
by: E. Robert Tisdale | last post by:
What makes a good C/C++ programmer? Would you be surprised if I told you that it has almost nothing to do with your knowledge of C or C++? There isn't much difference in productivity, for example, between a C/C++ programmers with a few weeks of experience and a C/C++ programmer with years of experience. You don't really need to understand the subtle details or use the obscure features of either language
121
9990
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode support IDEs are DreamWeaver 8 and Zend PHP Studio. DreamWeaver provides full support for Unicode. However, DreamWeaver is a web editor rather than a PHP IDE. It only supports basic IntelliSense (or code completion) and doesn't have anything...
51
13337
by: WindAndWaves | last post by:
Can anyone tell me what is wrong with the goto command. I noticed it is one of those NEVER USE. I can understand that it may lead to confusing code, but I often use it like this: is this wrong????? Function x select case z
46
4184
by: Keith K | last post by:
Having developed with VB since 1992, I am now VERY interested in C#. I've written several applications with C# and I do enjoy the language. What C# Needs: There are a few things that I do believe MSFT should do to improve C#, however. I know that in the "Whidbey" release of VS.NET currently
13
5029
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
1
1460
by: GS | last post by:
I got a combobox box that I load at load time. the Item and vales ended up in reverse order of each other, what went wrong? the database table has the following row code value ebay http://www.ebay.com google http://www.google.com yahoo http://www.yahoo.com However in the drop down list displayed value used ebay http://www.yahoo.com
98
4546
by: tjb | last post by:
I often see code like this: /// <summary> /// Removes a node. /// </summary> /// <param name="node">The node to remove.</param> public void RemoveNode(Node node) { <...> }
9
2114
by: Pyenos | last post by:
import cPickle, shelve could someone tell me what things are wrong with my code? class progress: PROGRESS_TABLE_ACTIONS= DEFAULT_PROGRESS_DATA_FILE="progress_data" PROGRESS_OUTCOMES=
20
2802
by: Daniel.C | last post by:
Hello. I just copied this code from my book with no modification : #include <stdio.h> /* count characters in input; 1st version */ main() { long nc; nc = 0;
0
7946
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8003
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6654
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5739
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5408
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3859
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3897
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1478
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1210
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.