Solved

Javascript to open a new url

Posted on 2012-04-07
11
239 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
  • 6
  • 5
11 Comments
 
LVL 82

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 82

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
 

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 82

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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

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 82

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 82

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 82

Accepted Solution

by:
Dave Baldwin earned 500 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
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…

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now