This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
How do I get the current location of an iframe?
Hi i want to get the complete URL, and with the methods i know i get the full url but of the iframe, and i want the 'final' document.location.href,
how can i get it?
i don't care if its php or js, but i'm guessing by my experiments that with PHp it's not possible...
If you want to know where you currently are:
Client side - javascript - you can use alert(window.location).
Server side - php - .$_SERVER["REQUEST_URI"] or $_SERVER['PATH_INFO'] depending on what you want.
Take a look at the top answer from this question.
It's important to note that it's (luckily!) not possible to get the URL of an iframe if the iframe's URL is from a different domain than the parent page. If you're trying to do that, you're probably out of luck.
Related
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Ways to circumvent the same-origin policy
Please help..
Mainly I want to parse a HTML from a different URL using JavaScript so I can find there if a class exists and I can show the result on my page if it exists or not.
I don't know your enviroment, but it looks like a jsonp :)
http://en.wikipedia.org/wiki/JSONP
1) You avoid same origin policy because You use src attribute of script tag.
2) You can have everything sent right into your callback function.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to encrypt HTML, CSS and JavaScript to prevent theft
Please tell how to encrypt html page surce code for any webpage using javascript function if not possible then please tell alternative ways..
In order for the source to be rendered, it has to be decrypted in the browser and a DOM constructed, which which point the user can use a DOM inspector to access the DOM and serialize it back to HTML (thus creating a reasonable facsimile of the original HTML).
Thus there is no way, alternative or otherwise.
This question already has answers here:
How do we control web page caching, across all browsers?
(29 answers)
PDF freezing browser - do I have enough information to isolate the cause?
Closed 8 years ago.
Basically, I need to remove the 'cache' part of request headers when requesting a particular static resource (a pdf).
Is this possible to achieve?
A bit more context:
I'm comparing two calls to a file (calls as in assigning the path of pdf to a src attribute of an iframe). One works, one doesn't. Using fiddler2 I've had a look at the traffic and it appears that the only difference is that the request headers of the request that doesn't work includes If-Modified-Since in the 'cache' part of it's headers. If I can remove this I think it'll solve the issues I'm having as I understand caching and iframes displaying pdfs can be potentially problematic. If I'm wrong, and it doesn't solve it, I'll at least have ruled that out as a problem.
EDIT: This is a problem exclusive to IE 8 if that's any help: https://stackoverflow.com/questions/13528332/pdf-freezing-browser-do-i-have-enough-information-to-isolate-the-cause
Like #Lee Taylor said, use a unique variable in your path. Mostly this is done with a timestamp since it's unique.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Persist javascript variables across pages?
how to exchange variables between two html pages
I am working on creating a "quiz" that allows users to answer questions, then passes their answer and current score to the next page for the next question. I used this article and was able to get the user's answer to pass through to the next window:
http://www.htmlgoodies.com/beyond/javascript/article.php/3471111/A-Quick-Tutorial-on-JavaScript-Variable-Passing.htm
The issue is that this passes the information through a form. Once I receive the score on the second page, I need to increment the score if the answer was correct. I can't figure out how to pass a javascript variable with an html form.
I feel like this should be a relatively easy fix, I'm just stumped.
Any thoughts or advice would be much appreciated!
xoxo
There are two obvious ways to maintain state in the browser without requiring that the server remember it between pages:
Cookies
localStorage
The latter is trivial to implement, but is only available in HTML5.
Note that neither is intended to be secure - a determined page hacker could set either to whatever value they wish.
You can submit a form using get method <form method="get" then use javascript to parse params in url. Reference here:
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How do I parse a URL into hostname and path in javascript?
I’m trying to parse the url of the page. For example the current page is location.href.
So the main page of my blog, if I use alert(location.href); it will return “http://diaryofthedead.co.cc/” in an alert box. If I use alert(location.href); on page two of my blog, it will return “http://diaryofthedead.co.cc/page/2” in an alert box. Is there any way to parse the URL to get the number at the end. Does anyone know how I could do that? Could I use wildcard or something, to do something like: location.href+”page/”+*; While * is equal to whatever follows “page/”, and then turn * into a variable?
You can use
var pagenum = location.pathname.match(/\/page\/(.*)/)[1];
It will extract anything past '/page/' in your URL;
Checkout this package jsuri
Or keep it simple http://james.padolsey.com/javascript/parsing-urls-with-the-dom/
URI.js is a library for working with URLs. It can not only parse URLs, but also offers a simple fluent API (jQuery like) for modifying URLs.
Take a look at the documentation on the location object http://www.w3schools.com/jsref/obj_location.asp
You first want the "pathname" part, location.pathname