Click to See Complete Forum and Search --> : need help
userb
October 12th, 2005, 04:48 AM
hi,
if some site uses this code
<script language="JavaScript">
var url = "http://www.aaaa.com";
var wh = 'width=250,height=250';
var time = 10;
//////////
var winopop;
window.onload = function(){
winopop = window.open(url,'news',wh);
winopop.focus();
window.setTimeout(function(){winopop.close()},time*1000);
}
</script>
they can open the site http://www.aaaa.com in a window for 10 sec and then auto close that window.
is there way to stop the window from closeing by adding a code inside the pages of www.aaaa.com
hepi
October 12th, 2005, 05:39 AM
Hi,
a) This is Javascript coding and not PHP.
b) Do you work on your own web pages or do you want to change the behaviour of web pages somebody else created?
It's hard for me to understand want you want to do.
Henning
userb
October 12th, 2005, 05:50 AM
well i am trying to stop other sites from opening my pages for 10 sec only
so i want to add a code in my pages which stops the code in there pages from closeing my site after 10 sec
example
site1 opens mysite in a window for 10 sec and then it closes
what i want
site1 opens mysite in a window for 10 sec "but a code in my page" stops the timer and the user stays in my site
userb
October 12th, 2005, 09:31 AM
any one has a fix ?
PeejAvery
October 12th, 2005, 09:58 AM
Careful with your function calls.
<script language="JavaScript">
var url = "http://www.aaaa.com";
var wh = 'width=250,height=250';
var time = 10;
function dopopup(){
winopop = window.open(url, 'news', wh);
winopop.focus();
milli = time * 1000;
window.setTimeout("winopop.close()", milli);
}
</script>
Dr. Script
October 12th, 2005, 03:33 PM
What seems to be asked for here is that an off-site page is being opened and closed. The intention is that the off site page have a script that would keep it from closing.
One solution would be to open your page on the onunload method. I don't know about its support, but it would be a clever idea, so it would open right back up.
Another way would be changing the name of the window, which may or may not be a security issue that cannot be worked around, or by changing the "main" of this window.
My personal favorite would be to check to see if it is a popup (check height or width for 250, check scroll bars, check status, etc ...), and if it is, then open your own site full screen, set focus to it, and close the popup. Hence, you will be taking their pop-up and closing it for them, and opening your site fullscreen.
Simply done by using:<script type="text/javascript">
if (document.all) {
height=document.body.clientHeight;
}
else {
height=window.outerHeight;
}
if(height == 250) {
window.open(location.href,"_blank","height="+screen.availHeight+",width="+screen.availWidth);
}
</script>I haven't tested it yet, but I don't see any bugs in it ...
PeejAvery
October 12th, 2005, 03:39 PM
http://www.aaaa.com in a window for 10 sec and then auto close that window.
is there way to stop the window from closeing by adding a code inside the pages of www.aaaa.com
Sorry, I misread this the first time.
The way the code is scripted, without real function identifiers nor window props for the close command, makes it impossible. The best that you can do is make it reopen if it is closed. That would be an annoyance.
userb
October 12th, 2005, 04:35 PM
tested it
still didnt work
i was told by some programer is that there is no way to stop it
the problem with the unload is that it will annoy the people that came to the page normaly
if there is a way that can detect and then redirect the visitor to a page with the unload that would be a great way to fight back
PeejAvery
October 12th, 2005, 04:56 PM
The way the code is scripted, without real function identifiers nor window props for the close command, makes it impossible.
Like I said, sorry about the confusion with my first post.
Dr. Script
October 12th, 2005, 05:47 PM
Well, I have trouble seeing what should come up and all because there are so many pop-ups. I don't know what should come up, etc ...
I do know thatthe window that is opened doesn't have the JavaScript code that I provided. Maybe you added it to the wrong page, or maybe you removed it. But the page that is popped-up should have this code, and then close by itselfand reopen to full screen, Again, I can't tell if that happens because it all looks like pop-ups from my end.
PeejAvery
October 12th, 2005, 11:07 PM
I just thought of something. You can possibly filter that out scripting out with PHP. The command file_get_contents() could read it into a string and then output it.
1. Name this PHP script something like "index.php."
2. Change the "$url = " and put the filename of the webpage which contains the close window code.
3. Load this PHP page.
<?php
$url = "FILENAME.HTML";
$content = file_get_contents('$url');
//DETECT CLOSE COMMAND AND ERASE IT.
$str = "window.setTimeout(function(){winopop.close()},time*1000);";
$content = str_replace($str, "", $content);
echo $content;
?>
Dr. Script
October 12th, 2005, 11:19 PM
Again, I think you are misunderstanding a bit ... that would be added to the page which opens the window. I think the original user needs code to be added to the page that is opened.
That would filter out from closing the window, if he had access to that specific page. However, if he didm, he could just as easily remove that line of code. I think code is intended to be added to the pop-up window to prevent it from closing, or at least that is how I took it.
PeejAvery
October 13th, 2005, 12:09 AM
Wow, I am dense. How was I totally missing that? I need to read the question twice through before posting from now on.
So basically userb, you want code that will keep a popup window from closing? The closest you are going to come to this is by making frames on your browser and having one of those frames be your page.
userb
October 13th, 2005, 03:25 AM
i'll post these info and hope it helps
here is an example of a page that uses the popup
http://www.arab1000.com/testp.html
and here is the page that opens
http://www.arab1000.com/cgi-bin2/rank/rankem.cgi?id=aaaa
which then directs the visitore after it counts his vote to
http://www.arab1000.com/starts1.html
which is a page with frams
i added the code to it but it didnt help
i can also add the code to
http://www.arab1000.com/cgi-bin2/rank/rankem.cgi?id=aaaa
Dr. Script
October 13th, 2005, 06:45 AM
The one with ?id=aaaa is the pop-up? Then add the code to that one. It *should* work, I'm interested i nwhy it doesn't. Perhaps there is a syntax error I'm missing ...
userb
October 13th, 2005, 08:48 AM
hi,
ok added to
http://www.arab1000.com/cgi-bin2/rank/rankem.cgi?id=aaaa
which calls this file
http://web2.arab1000.com/c.js
that has your code
but it didnt work
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.