We’d like to remind Forumites to please avoid political debate on the Forum.

This is to keep it a safe and useful space for MoneySaving discussions. Threads that are – or become – political in nature may be removed in line with the Forum’s rules. Thank you for your understanding.

📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!

ASP .Net / Javascript help needed

Hi guys

Does anyone have any idea how i can open a new broswer window to a specific URL and populate some text fields in the new window.

I tried using an iframe on a page, but i kept getting an error that the frame was null, or not an object.

Any ideas?

Comments

  • This is an interesting question but, unfortunately, I do not know the answer.

    I did wonder, however, whether you have tried the Microsoft ASP.NET forums in addition to this one ?

    Trevor
  • I'm just wondering if this would be of any help to you. Probably not I suspect but the site is a great resource nonetheless.

    Good luck with it in any case.

    Trevor
  • Here's the Javascript to open a new window and show a new page in the window:

    <script type="text/javascript">
    function open_win()
    {
    window.open("http://www.something.com/mypage.html");
    }
    </script>


    Does that help?
  • I've done this at work a few years ago but cant for the life of me remember it freehand and not at work for a week :-(

    I googled and got a chap asking this question:-

    Link Here

    Not sure you'll need all the javascript but will hopefully get you going! If you still need it in a week then PM me and will dig it out.

    I have asp page (say, 1.asp) that has a textbox. This page is available
    to me in read-only mode, meaning I know all the field names, functions
    names etc., but can't change anything.

    Now, I need to write .htm or .asp (2.htm or 2.asp) that will have a
    textbox and submit button. When user clicks on submit two things have
    to happen:
    1) 1.asp opens in new browser window
    2) textbox in 1.asp gets populated with textbox value from 2.htm (or
    2.asp)

    The reply was:-

    as I understood the two forms (1.asp and 2.htm)
    are exactly same (except button to send infos to 1.asp)

    function pop() {
    if(!(!truc) || !truc.closed) truc.close();
    truc=window.open('1.asp','','width=300,height=250' );
    txfer();
    }
    function txfer() { // copy content of each textbox from 2 to 1
    var a = document.forms[0].elements;
    var b = truc.document.forms[0].elements;
    for(var i=0;i<b.length;i++) if(a.type=='text') b.value=a.value;
    }

    in file '2.htm' :

    <input type=button onclick="pop();"
    value="Open Pop-Up and Transfer Datas">
    </form>

    or with your case (only 1 textbox + 1 submit button)

    file '2.htm' :

    <html>
    <script type="text/javascript">
    function pop() {
    var a = document.forms[0].elements[0];
    if(a.value.length<1) {
    alert('Fill the field of text')
    a.focus(); a.select();
    }
    else {
    if(!(!truc) || !truc.closed) truc.close();
    truc=window.open('1.asp','','width=300,height=250' );
    var b = truc.document.forms[0].elements[0];
    b.value = a.value;
    alert('that\'s done');
    }
    }
    </script>

    <form onsubmit="pop();return false;">
    Name : <input type="text">
    <input type="submit" value="OK">
    </form>

    </html>
  • jaydeeuk1
    jaydeeuk1 Posts: 7,714 Forumite
    Debt-free and Proud!
    edited 7 November 2010 at 11:51PM
    reason you may not be able to do it with an iframe could be cross domain security if yoursite is on a diff domain to one you are referencing. There are a couple of ways round it though. Also you're not trying to ref a https link are you, such as a logon form?

    However, the fact you get null or not an object suggests the code is incorrect, eg iframe is not correctly referencing the parent window. Even with cross domain issue, you still still get 'object' returned if you tried to alert the name of the frame, you just wont be able to write any data.
This discussion has been closed.
Meet your Ambassadors

🚀 Getting Started

Hi new member!

Our Getting Started Guide will help you get the most out of the Forum

Categories

  • All Categories
  • 352.5K Banking & Borrowing
  • 253.7K Reduce Debt & Boost Income
  • 454.5K Spending & Discounts
  • 245.5K Work, Benefits & Business
  • 601.4K Mortgages, Homes & Bills
  • 177.6K Life & Family
  • 259.4K Travel & Transport
  • 1.5M Hobbies & Leisure
  • 16K Discuss & Feedback
  • 37.7K Read-Only Boards

Is this how you want to be seen?

We see you are using a default avatar. It takes only a few seconds to pick a picture.