[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 248
  • Last Modified:

Javascript to open a new url

Hello,

I am not sure if this is possible but i need some javascript that will generate a http request with some content fields, and then open the requested url in the current window.

Thanks.
0
soozh
Asked:
soozh
  • 6
  • 5
1 Solution
 
Dave BaldwinFixer of ProblemsCommented:
On this page http://www.w3schools.com/js/js_ex_browser.asp , see "Open a new window and control its appearance".  You can add a query string to the end of the URL to pass parameters.
0
 
soozhAuthor Commented:
ok but i want to add CONTENT fields - not query string,
0
 
Dave BaldwinFixer of ProblemsCommented:
Content is sent in a URL with a query string in name/value pairs.  Can you give me an example of what you want to send?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
soozhAuthor Commented:
i do not want my data in the url.  Thats why i want to pass it as part of the body of the message...
0
 
Dave BaldwinFixer of ProblemsCommented:
There is no "body of the message" when you open a web page.  Your choices are limited to two: GET which puts the data in the URL, and POST which does not.  In both cases, the data has to be supplied in "name/value" pairs like you see at the end of internet addresses in your address bar.  Which form you use depends on the requirements of the web site.  You have to send the data in the form that they require.  Do you have directions from them about what they want you to do?  Can you give me the web address that you are trying to open?
0
 
soozhAuthor Commented:
I would like to do a post.  And add content fields that are not in the url...

do you have any generic code?
0
 
Dave BaldwinFixer of ProblemsCommented:
See here: http://www.w3schools.com/tags/att_form_target.asp  For POST, you need to use a <form> with a 'target' attribute of '_blank'.  The page that you POST the data to must be a server side page that can receive the data.  A plain HTML page can not do that.
0
 
soozhAuthor Commented:
Ok i have looked at this example.  

The reason i posted this question here is because i know nothing about get/post blah blah...

I know the question is a very basic one and anyone who has more than 5 mins experience with html/js can do it... but thats not me.

So really i would like an example that does not send the data as name/value pairs in the url.

Thanks.
0
 
Dave BaldwinFixer of ProblemsCommented:
This page http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_form_method_post shows an example of using POST to go to a new page.  If you are going to transfer data on the web, you need to spend your "5 mins" to learn about GET/POST and forms.  They are the defined ways of transferring info from one page to another.  The pages I have linked can tell you everything you need to know.
0
 
soozhAuthor Commented:
I am sorry but my question has not been answered.  I have asked for some example JS code because i dont know anything about it.  

It is becoming increasingly common that people answer questions by refering to a link that often does 85% of what you want.

I can search the web... but the reason i have posted the question here is because i only ever find 85% of my solution....
0
 
Dave BaldwinFixer of ProblemsCommented:
Your question, as you have asked it, is not answerable because what you are asking for does not exist.  You have not given me any examples of what you think you want so I don't see how I can give you sample code to show you what to do.  I have a hundred pages on the web that POST info to other pages so I know how to do it.  But until you give me enough information, I can not answer your question.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now