sending array name through window.open

  • hakexp
  • Born
  • Born
  • hakexp
  • Posts: 1

Post 3+ Months Ago

Scenario:

using php to write a link which opens a pop-up window.
Within the parameters there window name that gets sent is an array

projectName[x]

Is there a rule that states arrays cannot be sent through a function call for a window.open? You can't have spaces, but what about []

<a href="#" onClick="window.open("test.html","projectName[<?echo x;?>]?>","220","220")>pop-up</a>

Any ideas?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • RichB
  • Guru
  • Guru
  • User avatar
  • Posts: 1121
  • Loc: Boston

Post 3+ Months Ago

This is very odd. Whenever I try to send any non-alphanumeric character in the second string argument of window.open I get invalid argument. On the other hand there seems to be no objection to assigning a string containing a non-alphanumeric directly to the window.name property, so in an attemp to get around the invalid argument I tried creating the new window with a blank string for the second arg and then assigned the new value to it directly and that seemed to work.

Code: [ Select ]
<?
$x=5;
?>
<html>
<head>
<script type="text/javascript">
<!--
function openwindow(fileName, winName)
{
    win = window.open(fileName,"","width=220,height=220")
    win.name = winName;
}
//-->
</script>
</head>
<body>
<a href="#" onClick="openwindow('test.html','projectName[<? echo $x; ?>]')">pop-up</a>
</body>
</html>
  1. <?
  2. $x=5;
  3. ?>
  4. <html>
  5. <head>
  6. <script type="text/javascript">
  7. <!--
  8. function openwindow(fileName, winName)
  9. {
  10.     win = window.open(fileName,"","width=220,height=220")
  11.     win.name = winName;
  12. }
  13. //-->
  14. </script>
  15. </head>
  16. <body>
  17. <a href="#" onClick="openwindow('test.html','projectName[<? echo $x; ?>]')">pop-up</a>
  18. </body>
  19. </html>


I put an alert box inside my test.html file to make sure that the value was assigned and it showed correctly.

Code: [ Select ]
<html>
<head>
<title>
blah blah
</title>
<script>
alert(self.name);
</script>
</head>
<body>
blah
</body>
  1. <html>
  2. <head>
  3. <title>
  4. blah blah
  5. </title>
  6. <script>
  7. alert(self.name);
  8. </script>
  9. </head>
  10. <body>
  11. blah
  12. </body>


I haven't been able to find documentation of the non-alphanumerics in the second string argument anywhere.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 83 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.