Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can invisible one hyperlink window 4

Status
Not open for further replies.

marjansayyad

Technical User
Dec 26, 2013
3
0
0
US
Hi,
I want to run one of our websites on the background of my webpage, because I am using its result on my webpage, but I do not want it has been seen by users.
Here is my code:
-------------------
<button onclick="myFunction()">Click</button>
<script type="text/javascript">
function myFunction() {
var win = window.open(" '1366002941508','width=80,height=20,left=1,top=200');
setTimeout(function () { win.close();}, ss);
}
</script>
--------------------
When I add "visible=none" to the window, " cannot be run, but I need it to be run on background, finally it will be closed after some seconds.
Also, I tried with frame, but I think we cannot run any webpage (like ) on frame. I am really stuck:(
Does everybody have any idea about that?
I really appreciate your help.
 
I tried with frame, but I think we cannot run any webpage (like ) on frame.

Given that the sole purpose of the iframe element IS to allow external URLs to be displayed, you are incorrect.

AND if you do not want the page to be displayed to the user, WHY are you using an onClick event, which requires user interaction, to trigger it?

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Code:
<html>
<head>
<script>
function myFunction()
{
	document.getElementById('myFrame').src='[URL unfurl="true"]https://xxx.com';[/URL]
}
</script>
</head>
<body>
<button onclick='myFunction()'>Click Me</button>
<iframe id="myFrame" style="width:0px;height:0px;display:none"></iframe>
</body>
</html>

Though I wasn't expecting what I got when I tested it! - Is this a dodgy post?

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music
 
Hi,
Thanks for your answer. I just changed it to see the result, but it says " the content cannot be displayed in the frame" (please look at the attached file ):
-------------------------- Example --------------
<html>
<head>
<script>
function myFunction()
{
document.getElementById('myFrame').src='}
</script>
</head>
<body>
<button onclick='myFunction()'>Click Me</button>
<iframe id="myFrame" style="width:800px;height:300px"></iframe>
</body>
</html>
---------------------------------
 
Have you read and comprehended the error message?
You most probably won't have this problem, if you allow your own website to be displayed inside a frame.
The error says: "...the publisher of this content...", which is yahoo, "does not allow it to be displayed in a frame".
So you can't display yahoo.co, in a frame, but you most probably can display your own content in a frame.

Bye, Olaf.
 
so basically only more modern browsers and then it's totally flaky

Yep! Situation normal, and by the time all browsers catch up, everything else will have moved on and it will be redundant :)

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
What you seem to need is an AJAX technique of doing a httprequest from javascript. You then should neither open a window invisible and close it after a timout, not use an iFrame for this, but use XMLHTTPREQUEST.


This is included much more elegantly to use in other javasctript libraries, eg jQuery.

Bye, Olaf.
 
Hi

Olaf, the W3Fools site was created for a reason : to throw attention to W3Schools problems. Better link to XMLHttpRequest on MDN or XMLHTTPRequest on MSDN.

For example the referred pages mention nothing about Cross-origin resource sharing. Due to Same-origin policy neither AJAX will be able to get content from the Yahoo! site, unless they explicitly allow it. ( My guess : they will not. )


Feherke.
feherke.ga
 
Good point, but the OP said: "I want to run one of our websites on the background of my webpage", so neither xxx.com nor yahoo.com are really involved.

Besides, I also dislike w3schools, but to get the essential stuff you can pick up code from there, too.

The site where I learned HTML best was SelfHTML, mostly german and therefore only known in germany. I used english resources later on, but mostly for other things than HTML.

Bye, Olaf.
 
Hi

Correct, based on that sentence. Maybe would better to rephrase more generally :

The OP needs similar permission on the target server to alter either the [tt]X-Frame-Options[/tt] or the [tt]Access-Control-Allow-Origin[/tt] HTTP response header, as both has to be done on the target server. As [tt]X-Frame-Options[/tt] can also be set in [tt]meta[/tt] tag, while [tt]Access-Control-Allow-Origin[/tt] not, (s)he has more chances with frame than with AJAX.


Feherke.
feherke.ga
 
As the OP is pulling info from their own website, I would still be interested to know what overaall objective they are trying to achieve. Once we have that information, we will be in a better position to offer suggestions for a solution.


Keith
 
Hi Everybody,
Thanks for all your answers. I am not professional in coding so, I decided to change my code. Now I want to run the new link in a new tab then close it after 2 seconds, and I want this new tab be opened once, but my problem is:
when I back from any lnk1,or lnk2, the has been opened again. How can I fixed that?
Here is my code:
--------------- example--------
<html>
<body>
i=1
<table >
<tr><td > </td></tr>
<tr> <td >
<script type="text/javascript">
if ( i=1 ) {
var win = window.open(" '_blank');
setTimeout(function () { win.close();}, 2000);
i=2
} </script>
</td> </tr>
<tr><td >lnk1 </td>
<td > lnk2 </td>
<td > lnk3</td>
<td > ... </td> </tr>
</table>
</body>
</html>
------------------
Thanks for your help!!
 
First of all you should stop using a porn site for sample code.

Bye, Olaf.
 
Ha Ha, very funny Olaf.
As per my previous question to the OP, what are you actually trying to achieve.
Sometimes you need to step back and look at the big picture rather than get bogged down by specific problems in developing a solution.

Keith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top