I would like to know if I somehow can browse to i.e http://avatars.io/twitter/billgates
and then store the url we got redirected to * in a variable.
which in this case will be http://pbs.twimg.com/profile_images/558109954561679360/j1f9DiJi_normal.jpeg
Using JavaScript and without the user noticing.
The reason I want to do this is because I want to change a few things in the final url before storing it.
Related
I am trying to read the URL to pull the data out of it then split the URL at ? without reloading the page. How would I do this?
The reason why I am doing this is so that I can pass a name from one page to another to display.
No jQuery please as I can't use it in my development workspace.
My URL looks like this http://localhost:3000/view/1?Username=Dan I want to read the Username=Dan then remove it from the URL so the client can't see it.
If you want to save state of your application, don't use URL parameters in this way, store it in localStorage:
Save it on the first page:
localStorage.setItem('name', 'Dan');
And read it on the following page:
let name = localStorage.getItem('name')
Or, if you don't need it to live longer than the session, use sessionStorage (it has an identical API).
I used query string now to adress some special (dynamic) content. Now is my question: Is it possible to change the actual query by JS when i change the dynamic content, so that i could refresh the site with the same content and not with the default query values.
Yes, you can achieve this by changing window.location.href if you want the browser to go to a different URL. For example, go to http://google.com and now open the JavaScript console of your browser and put:
window.location.href = 'http://google.com/?q=abc'
If you only want to change part of the URL (query string), there are a bunch of ways to do that. You can do it manually and set a whole new URL or use libraries/plugins to help you do this. How to parse the query string: How can I get query string values in JavaScript?
i hope i understood the question right...
i guess that browsers wont like to allow you to touch their Request object...
but i think of two methods:
you can redirect the browser to the new changed link using
window.location='?q=changed_search'
in your other scripts, dont reference the real Querystring, but a (private to the page) copy of it which you can change wherever you want.
Note: QueryString is mostly input from the user, and i dont think it should be needed to change without the page being resubmitted (as suggested in 1).
cheers.
I have an SSRS report with a function that detect url of report (the report shows tvo different value, dependending on url)
I use:
="javascript: var name=document.URL; var n=name.indexOf('hsbportalen.se'); if(n > 0) { void window.open('http://www.google.com',800,800,'_blank')} else { void window.open('http://www.msn.com',800,800,'_blank')}"
But what I want now, is how can I set a value in a textfield (Textbox42) with a JavaScript dependign on url.
What you'll find is that SSRS does not support JavaScript, period. The only functions that you can pass through SSRS are those that your web-browser can interpret outside of a script file. From what I've found, this is a very limited set of commands.
For instance, you can use Window.Open('') and void() and a few others. I've never been able to get an If statement and certainly not a parse() to work through SSRS.
I've had to do this a couple of times and, if you're in the same boat I was, you'll find the easiest way is to do one of the following:
Option 1: Going from one SSRS Report to Another, Pull data from URL
Go to the source of the current URL and reconstruct the URL you are receiving. For instance, you can use the "Go to URL" action to create a custom URL to a Report that will drop the breadcrumbs and use the Report Server rs & rc parameters. Basically, to make this work, whatever variable you want to parse out of the URL would first be created as a parameter of the appropriate type in your target report and then you would pass that value through the URL to that report.
Scenario 2: Coming from an external website, Pull data from URL
I've had to do this too, but it's a bit more involved. What you need is an intermediate webpage. One that Opens and Closes immediately, and all it basically does is redirect you to where you want the user to go. To accomplish this, follow these steps:
First, create a parameter in the report you want to read the URL. The parameter should be of the appropriate type to store the data to be read from the URL (i.e., URL_Data)
Second, create an intermediate webpage that will lie where the URL is pointing. You can construct the page to open with a message like "Loading..." or "Please wait..." (just in case the user sees it).
Third, in the script of the intermediate page, have it parse the data from the URL that you are trying to capture. Then, incorporate that data into a custom URL that points to the desired SSRS report and includes the URL data as the parameter.
See here and here for more information on how to generate custom URLs that can incorporate parameter values.
http://SSRS_Server/reportserver/Pages/ReportViewer.aspx?/directory/Sample_Report&URL_Data=URL_Snippet
Finally, finish off your JavaScript on the intermediate webpage to open the SSRS URL in a new window and close the current page.
Now, you can use the values of that parameter wherever you want.
I thought this would be easy but I guess I was wrong. I have a url;
http://www.example.com/aa/bb.html?uid=123
using javascript jquery and html, I am able to retrieve data from a json api with the uid in the sample url above. However, I don't want that url displayed like that in the address bar after the data has been parsed. Rather, I need it to display as;
http://www.example.com/aa/item-title
where item-titleis the title of the data referenced by uid=123.
A php mod-rewrite would have been ideal, but this project does not make use of server side scripting.
Thanks in advance
If you change or modify the URL then the browser try to fetch data fro the new URL. You can do something with the part of URL after # mark.
Like :
http://www.example.com/aa/bb.html?uid=123#old_part
to
http://www.example.com/aa/bb.html?uid=123#newpart
I can see only one solution to your problem as you don't want to use mod_rewrite. You can redirect from first page just changing the URL based on the given uid value to the next page you want to display.
First page - read parameter uid and build the redirect URL based on the title(not any other stuff in your first URL page)
Redirect to the built URL
In redirected page do the rest of page specific stuff.
I am working on an AJAX website where there are two search parameters. I did some mod-rewrite and checking for $_GET variables so that i can do something like..
site.com/var1/var2/ -> automatically do the search based on the parameters.
Now what I want is for people who do the search manually, to be able to have the url in that format. The only method that I've been able to find has to do w/modifying the url using..
location.hash = 'foo';
which would make it something like.. site.com/#var1
Which isn't as nice as the mod-rewrite. What I have found that works is if in my search function that does the ajax call i have this code
// avoid appending further variables if there are already variables
if(location.href == 'some absolute website path')
location.href = var1+'/'+var2+'/';
This will work, but basically forces the page load and then my auto search php/javascript will kick in due to the mod-rewrite. SO this works, however it involves an extra page refresh that I would rather avoid.
Any better solutions out there? Ideally if i was able to use location.href where it didn't cause the page to load once i change the value, but would just change in the url would be ideal (while maintaining my mod-rewrite links, w/out the # marks).
I am using jquery and php.
It's that way by design, there is no way yo change the url or path without causing a new request. Regards.