I've an old website, navigation in an frame at left, pages at right.
I want when an page is url'd directly the nav (left frame) shows also.
Until now I was an js working, but I don't know from when it are not working,
now returns this message:
Forbidden
You don't have permission to access /master.html on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache/2.2.10 (Unix) mod_ssl/2.2.10 OpenSSL/0.9.8i DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at www.cpis.es Port 80
The code I was using is
http://www.webmasterworld.com/forum21/1205.htm
Call this javascript code from the HEAD section of each child page. The code creates a variable from the URL of the page, and then passes that variable in the new location's URL. This means a "master" frameset can load this exact page in the content section:
<SCRIPT LANGUAGE="JavaScript">
passpage = document.URL
if (top.location == self.location)
top.location.href="master.html?" + passpage
</script>
Then create just one "master.html" page. It holds the JavaScript code to decipher whatever URL is passed after the "?" and it writes that page into the content frame:
<html>
<head>
<title>Master Frameset</title>
</head>
<script language="JavaScript" type="text/javascript">
origURL = parent.document.URL
contentURL = origURL.substring(origURL.indexOf('?')+1, origURL.length)
document.write('<frameset cols="20%,80%"><frame src="leftnav.html" name="nav"><frame src="' + contentURL + '" name="content"><\/frameset>')
</script>
</html>
Thanks, Guillermo.
Sorry for delay.
Looks like the problem is in this little peace of javascript:
passpage = document.URL
if (top.location == self.location)
top.location.href="master.html?" + passpage
It should be:
passpage = window.location.pathname;
if (top.location == self.location) {
top.location.href="master.html?" + passpage;
}
You have to change that code in each page which you have in the link list. I think that should fix the problem.
I just checked the website and it seems to be working now. My guess is that there was no file located at http://www.cpis.es/master.html on server.
If the problem still exists please provide steps so we can reproduce it and see what went wrong.
Thanks Maiku Mori,
in order to properly test the problem please do the next:
go to www.cpis.es
click the second option in the menu (CoPrint)
ok, you see the leftnav + the page
now go directly to the page
go to www.cpis.es/coprint.htm
error, you got the forbidden page.
Related
For some reason, document.location.href , window.location.href , and window.location.replace is not working, I'm using localhost for now and I don't know how to redirect it to another webpage. I tried adding http:// on front, it's still not working, I tried making it redirect to another online website, It also didn't work. I read a lot of thread already and tried them but none of them worked for me.
var loginBut = document.getElementById("RDbtn1");
loginBut.addEventListener("click", checklogin);
function check(){
document.location.href = "http://localhost/some/directory/here";
alert(document.location.origin + '/some/directory'); // I just use this to know that the button is being pressed.
}
html:
<!-- some code here-->
<li><button class="login1" id="RDbtn1">LOGIN</button></li>
<!-- some code here -->
I believe you should redirect to particular html page and should give the port on which your local host application is working
document.location.href = "http://localhost:8080/some/directory/here/file.html";
It is window.location (nothing or replace or href) - document.location is normally used to get the actual page
What's the difference between window.location and document.location in JavaScript?
If you are on the same server, no need to qualify the page but I would add the actual page you try to load
window.location = "/some/directory/here/index.html"
I'm trying to redirect all my site mobile traffic to one page.
so I added redirect code in header.
<script type="text/javascript">
<!-- if (screen.width <= 699)
{ document.location = "/page/mobile/";
}
//-->
</script>
The problem is that after redirecting script continuous executing because header is the same on the whole site. so it's refreshing the page over and over again.
I want javascript to check for the /page/mobile/ in url and if it's there, do not execute redirect.
How can I achieve this? Thanks!
Do this.
if ( window.location.pathname !== "/page/mobile"){
window.location.href = "https://[your-host-name]/page/mobile";
}
So you can use window.location.pathname to access your path after host (and port)
https://developer.mozilla.org/en-US/docs/Web/API/Window/location
check window location in your if condition
if (window.location.href.indexOf("/mobile/")>-1){
console.log("You are on mobile page")
}
Hi I have multiple pages that reside in an iframe and I would like them to open in the parent page when say a search engine indexes them or people directly link to them.
Example:
-this page will be the parent page and have an iframe
-this will be first page.php
-then there will be second page.php, third page.php, fourth page.php, ect.
I would like it if someone linked to any of the pages that require the iframe to load the parent page with the iframe and load the url into that iframe. So if someone links to say third page it will load the parent page and load third page in the iframe.
I have tried the following scripts that I have found from posts across the web but they only load the parent page with the original src in the frame.
<SCRIPT LANGUAGE='javascript'>
try {
if (top == self) {
top.location.href = 'parent page.php';
}
} catch(er) { }
</SCRIPT>
And
<script type="text/javascript">
if (window == top) {
var url = 'window.location.replace("parent page.php?var1=' + window.location.href + '")';
eval(url);
}
</script>
I also tried:
<body onload="refreshFrame();">
Then I saw the post on Open iframe page in parent frame (javascript) here and it just brings up the page that was linked to and not the iframe.
The pages in the iframe are dymanically created as well so idk if that has anything to do with it or not.
But nothing seems to open the page inside of the iframe on my site it only loads the parent page with the original src first page in it. So idk if this is possible with either javascript or php.
Also idk if anyone knows how this practice effects seo there are not many words and no tags on the parent page so I was just curious about that too.
Thanks
Did you try use the base tag in you iframe pages? Something like:
<base target="_parent" />
UPDATE
OK, so in your scenario you need to know if the current page is loaded on brownser or via iframe. And if it's not on iframe, redirect to your another page where you calling the iframe.
First thing first, check if the current page is inside a iframe with js:
<script type="text/javascript">
if ( self === top ) {
//Its not an Iframe;
}
</script>
Now that we know if the page isn't load via iframe we can use a redirect inside that if statament:
window.top.location="http://www.yourdomain.com";
Now you need to make sure after redirect the page, the iframe src attribute will be the same url it was before. I'm assuming you can do that with a get parameter int the url? Let me know if find trouble in that part.
UPDATE2
Just add a get parameter in the url as i mentioned above. Something like this:
<script type="text/javascript">
if ( self === top ) {
//Its not an Iframe, needs redirect:
var url = window.location;
window.location="http://www.yourdomain.com/index.php?iframe="+url;
}
</script>
Now in your index.php ( or whatever is the page that contain the iframe):
<?php
$iframe_url = (isset($_GET['iframe']) && !empty($_GET['iframe'])) ? $_GET['iframe'] : "initial-url-content";
?>
<iframe src="<?=$iframe_url?>"></iframe>
Listen this is main site link >>> http://magazinerpros.blogspot.com/
Now i want that if someone click on the above link. then it should open to hold another link too. like you see in Example #2. that hold extra frame link { http://www.inframe.com/p/preview.html? } before the main link.
Example #2
http://www.iframe.com/p/preview.html?url=http://www.inframe.com
I tried to add script on my testing site, but it continuously loading when visit it.
Script that i added in the below site.
<script type="text/javascript">
window.location.replace("http://www.iframe.com/p/preview.html?url=http://redirectssite.blogspot.com/");
</script>
http://www.inframe.com.
So please give me only javascript or jequery script. To make this redirection possible. which you see in example #2. So what script should i add in the site. so that after visiting it holds that another frame link before it in addressbar.
Looks like you are creating a redirect loop.
Either check the URL, like:
<script type="text/javascript">
if (window.location !== "http://redirectssite.blogspot.com/") {
window.location.replace("http://www.iframe.com/p/preview.html?url=http://redirectssite.blogspot.com/");
}
</script>
From the below script, it would work work fine
<script type="text/javascript">
if ( !(window.location !== window.parent.location) ) {
window.location.replace("http://www.inframe.com/p/preview.html?url=http://redirectssite.blogspot.com/");
}
</script>
I have two iframes in a HTML page with 50% of the screen shared by both.
In the first iframe http://www.google.com is opened and in the second iframe http://www.nytimes.com is opened.
On Page Load, the page is automatically redirecting to http://www.nytimes.com.
What could be the problem for this?
Most likely, the nytimes.com home page has framebuster script on it.
Their home page include this JS file which contains the following code:
(function() {
if (window.self != window.top && !document.referrer.match(/^https?:\/\/[^?\/]+\.nytimes\.com\//)) {
var expTime = new Date();
expTime.setTime(expTime.getTime() + 60000);
document.cookie = "FramesetReferrer=" + document.referrer + "; expires=" + expTime.toGMTString() + "; path=/";
top.location.replace(window.location.pathname);
}
})();
This cause the behavior you see.
To protect against this, see the following question here: Keeping pages inside an iframe
Simply because nytimes.com dislike frames and wants to use all of your browserspace.
Why would you ever make a site like that anyway?
i am guessing that you mean that the iframe container is being redirected. maybe you want to check for some sort of iframe inclusion detection. take a look at: From the server is there a way to know that my page is being loaded in an Iframe
Check this out OWASP - ClickJacking
Only for Chrome
<iframe id="my_frame" sandbox> </iframe>
Works great for me ... :)