?
Solved

Javascript to open a new url

Posted on 2012-04-07
11
Medium Priority
?
245 Views
Last Modified: 2012-05-10
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
Comment
Question by:soozh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 37819796
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
 

Author Comment

by:soozh
ID: 37819890
ok but i want to add CONTENT fields - not query string,
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 37820195
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
Independent Software Vendors: 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!

 

Author Comment

by:soozh
ID: 37820733
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
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 37820747
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
 

Author Comment

by:soozh
ID: 37826599
I would like to do a post.  And add content fields that are not in the url...

do you have any generic code?
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 37826618
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
 

Author Comment

by:soozh
ID: 37826665
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
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 37828467
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
 

Author Comment

by:soozh
ID: 37854382
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
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 2000 total points
ID: 37854595
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

Independent Software Vendors: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question