Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Popup Window + Get Text From Popup Window

Posted on 2004-04-18
12
Medium Priority
?
594 Views
Last Modified: 2012-08-13
I have this javascript. Which opens a popup when you click on a button. Then it checks every 2 seconds if the text in the popups contains a certain string.

It works the first time it does textsearch() but after that it always gives an error what is wrong?

Also, why does it give an error if I leave the window it creates open, reload this page with the javascript, and click on the button again? And how to prevent this error?

<html>
<head>
<script language="javascript">

window.onerror = catcherror;
var wnd = null;

function linkwindow()
{
      wnd = window.open("http://www.kingsofchaos.com/recruit.php?uniqid=36tcb54e", "LinkWindow");
      textsearch();
}

function textsearch()
{
      if (wnd)
      {
            var txt = wnd.document.documentElement.innerHTML;
            if (txt.indexOf("is building an army of") != -1)
            {
                  document.forms[0].msg.value = 'OK!';
                  self.status = "message found";
                  return;      
            }
            self.status = 'message not found (retry in two seconds)';
      }
      setTimeout('textsearch()', 2000);
}

function catcherror()
{
 alert("Error");
}
</script>
</head>
<body>
<form>
<input type=button value="link" onclick="linkwindow()">
<input type=text id=msg size=60></textarea>
</form>
</body>
</html>
0
Comment
Question by:TheClickMaster
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
12 Comments
 
LVL 12

Accepted Solution

by:
venkateshwarr earned 1200 total points
ID: 10856651

You cannot access properties of a webpage that is outside of your domain...
So this is not going to work.
0
 
LVL 63

Assisted Solution

by:Zvonko
Zvonko earned 800 total points
ID: 10856979
The upper does say: if your source is not running on a page with this domain: "*.kingsofchaos.com", then it will not work.
So what is your url for upper page?
If the domain is same, why do you use JavaScript for the check? Why not php?
If you want to do it on client side, can you use ActiveX?
0
 
LVL 5

Author Comment

by:TheClickMaster
ID: 10857325
The restriction with security, thats what I feared. The URL is not the same domain as the other page so I can't access it.

I could use ActiveX, but that would make it IE only?

0
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

 
LVL 63

Expert Comment

by:Zvonko
ID: 10857541
Yeap.
0
 
LVL 5

Author Comment

by:TheClickMaster
ID: 10860850
Ok then it will not be possible.
So is there really no workaround or anything?
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 10860885
No there is not.
And it has a good reason: Security
Imagine that your window could read any other frame or window. Then you would be able to read fields and text from other domains and examine passwords, credit card numbers and so on.

0
 
LVL 63

Expert Comment

by:Zvonko
ID: 10860912
By the way, your script is allowed to iverwrite the foregn domain window, but not to read it. Reading is more dangerous then writing.
The exception of that security SandBox model is the HTA page. It is exactly the same as html page but runs as an application.
Therefore it can not be displayed from a web server.
It can run only localy when renamed to extension *.hta and only in IE browser.


0
 
LVL 5

Author Comment

by:TheClickMaster
ID: 10860972
Ah this is my first question and I didnt know how to split points :(
I will ask to have some points given to Zvonko.

0
 
LVL 63

Expert Comment

by:Zvonko
ID: 10861074
No problem.
It is only funny because it relates to your account name :)
0
 
LVL 5

Author Comment

by:TheClickMaster
ID: 10861662
My website http://theclickmaster.com is what this javascript was meant for =P
0
 
LVL 5

Author Comment

by:TheClickMaster
ID: 10863378
Allright, thanks a lot Lunchy.
Thanks also to venkateshwarr and Zvonko.

0

Featured Post

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question