Javascript to edit URL - javascript

I would like to use javascript to grab a URL parameter, in this case the "fbclid" parameter from a facebook ad link click.
I want to rename that parameter, so I can properly import it into my CRM and store it. My CRM can only do this with a specific type of parameter name.
So for example, if the URL was:
mysite.com/?fbclid=123456
I would like to turn that into:
mysite.com/?cf_1=123456
And fyi the value of 123456 is autogenerated during the link click, it's not a static number. Sorry if that's obvious, I'm new to this and wanted to be crystal clear.

Related

Can we ignore all parameters in URLs using a switch somewhere for their merchant account?

My client has text in their URL which are the same name as the Mention Me parameters. This means that despite them passing me locale=en_GB in the tag we ignore this and override it with the locale=uk-uk that we see in their requesting page URL.
How can I avoid this so that the correct parameters are used from the Javascript tag only and we ignore any other rogue parameters that appear in the URL?
Edit brand > advanced options
You can select the second option in the advanced options area of the edit brand view. This will allow you to only accept parameters from a requesting URL if it has the format "mm_" first e.g. "mm_locale=."
Using this method we are able to ignore the incorrect parameters that previously were overriding the correct Javascript parameters.

How to find path for on submit text box

I'm trying to reference a URL in a local application and am having difficultly finding the correct path to reference.
It uses a value that the website transforms into another value for the page requested.
The main URL is http://exac.broadinstitute.org/
My inputs contain variations of rs113488022 , which the website will turn to a variant
http://exac.broadinstitute.org/variant/7-140453136-A-T
Unfortunately I do not have this variant value to pass directly,and am looking for the path of the on submit action from the front page.
Yikes, that is some horrible HTML code.
But if you inspect the input element you find that the form has a simple action /awesome, and the input’s name is query. As a consequence, you can simply perform a GET on the following URI:
http://exac.broadinstitute.org/awesome?query=rs113488022
Be prepared to process redirects, because the above will give you an HTTP response of 302 FOUND with a redirect location (which is the URI you found).

How to restrict access to a page in rails unless the user arrived by following the link from a specific page?

I am making an online computer based test in Rails. Each question has a page URL of the form /questions/<id> .
There is a 'next' button on each question's page which points to the next question, like /questions/<another-id>. I don't want the user to manually be able to type the URL of any question and go to that page.
Is there any way I can accomplish this, preferably a server-side solution.
You can use :
Friendly ID Gem, That will convert your ID to a slug, So that the end-user can't determine what exactly is passing into URL parameter.
I have one server side solution for you may be that will solve your problem explained here as below...
Assume, You have a fixed link where a user can start the test.
Once a user start the test, then add a question-id into session as like below...
session[:current-question-id] = params[:question_id]
Always check the next question id by increasing one into sesssion question id, If matchs then show the question or do nothing redirect to back.
That solution will work, If you have sequence of question like 1,2,3...n.
A bit like Bharat Soni:
You can build an url with an id built by combining your question Id and a random number linked to user session.
You can combine this two value using a SHA1 (or algorithm of your choice). For example :
question id : 123
secret session hash : 857c9e05-8ad0-4d6b-8112-5f442a731dc1 (SecureRandom.uuid on sessions#create)
Calculate your digest :
Digest::SHA1.hexdigest "#{question_id}#{secret_session_hash}"
=> e951774237433335a6c9c0928d5691ca0c2a31b5
build your url :
website/question/123?key=e951774237433335a6c9c0928d5691ca0c2a31b5
You have to ensure in your controller that the digest you receive in params[:key] is the same that the digest you calculate.
This way you can reasonably ensure that your user is not cheating and that he can't give url to another person.

Follow shortened url then return JavaScript

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.

Fill field in SSRS with javascript

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.

Categories