Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New to the CF scene
    Join Date
    Jul 2018
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    JS help - Page needs to open in same window.

    Hi,

    I'm new to Scripting Can someone please help with the below requirement.

    I have a script where redirecting to different URL on load the page, I'm using window.location.replace(redirectURL). Now I need to update the script with satisfying below conditions.

    //check window exists
    //if it exists get the window name and then use that window to open the URL
    //if window doesn't exist let open its own window.

    Can someone please help ?

  2. #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Location
    Here
    Posts
    3,825
    Thanks
    58
    Thanked 688 Times in 683 Posts
    Which part isn't working? Please show your code so far

  3. #3
    New to the CF scene
    Join Date
    Jul 2018
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by xelawho View Post
    Which part isn't working? Please show your code so far
    Hi xelawho,
    Thanks for responding. I have this code below and I need to add new feature to this code.

    =======
    Code:
    <!DOCTYPE html>
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
       <meta http-equiv="Access-Control-Allow-Origin" content="*"/>
       <title>CTI Siebel Launcher</title>
       
    <script>
      function getParameter(name)  {
            var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
            if (results==null){
               return null;
            }
            else{
               return decodeURI(results[1]) || 0;
            }
       }
        function createCORSRequest(dealerCode, phoneNumber) {
                 
    			 //check window exists 
    			//if it exists get the window name and then use that window to open the URL
    			//if window doesn't exist let siebel open its own window
    			 
    var redirectURL = "MyRedirectURLHere"+"&LOC="+dealerCode+"&CALLNUM="+phoneNumber;          
                 alert("Launching Siebel " + redirectURL);
                 window.location.replace(redirectURL);
        }
    
      
        function initialize() {
            var username = getParameter('username');
            var phoneNumber = getParameter('phoneNumber');
            var dealerCode = getParameter('dealerCode');
            createCORSRequest(dealerCode, phoneNumber);
       }
       
    </script>
     </head>
    <body onload="initialize()">
            <div id="div1"><h2>Launching Siebel.....</h2></div>
     </body>
    </html>
    =======

    Thanks,
    Rajesh
    Last edited by vinyl-junkie; Jul 13th, 2018 at 02:46 PM. Reason: added code tags

  4. #4
    Senior Coder deathshadow's Avatar
    Join Date
    Feb 2016
    Location
    Keene, NH
    Posts
    3,091
    Thanks
    4
    Thanked 448 Times in 437 Posts
    Why is this even being done client-side? In a 1990's character encoding at that?!?

    ... and WHICH "window" exists? If you mean the window OBJECT in JavaScript, it always exists so... that doesn't make any sense either.

    Just what are you trying to do here?
    “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies and the other way is to make it so complicated that there are no obvious deficiencies.” – C.A.R. Hoare, The 1980 ACM Turing Award Lecture
    http://www.cutcodedown.com

  5. #5
    New to the CF scene
    Join Date
    Jul 2018
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by deathshadow View Post
    Why is this even being done client-side? In a 1990's character encoding at that?!?

    ... and WHICH "window" exists? If you mean the window OBJECT in JavaScript, it always exists so... that doesn't make any sense either.

    Just what are you trying to do here?
    http://127.0.0.1:7101/FileBasedAppli...ealerCode=2010
    http://127.0.0.1:7101/FileBasedAppli...ealerCode=0301

    When we click on the above link it always open with some constant names with prefix like either - Siebel Automotive - SOA017 or Siebel Automotive - SOA012, is there any way we can capture this previous reference and based on that can we determine whether Siebel window open or not ? (Siebel application supports only IE)

    Right now when I click on first one it opens in IE window, then If I click on 2nd link it opens in same window in new tab. My requirement is If I click on 2nd link it should open in same window where first window is already opened. Is this doable ?

    Thanks!

  6. #6
    New to the CF scene
    Join Date
    Jul 2018
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Please, Anyone can help ?

  7. #7
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    19,536
    Thanks
    220
    Thanked 2,712 Times in 2,686 Posts
    Which of the three places (new window, new tab, same tab) web pages open is completely under the browser's owner's control. You can only suggest where it should open in your code and the browser can be set to ignore your suggestion and open it where the browser owner wants it to open.

    Your visitor is supposed to be the one deciding what opens where - that's why the target attribute was made obsolete in 1997. It was only valid in HTML 3.2.
    Most people don't want new browser windows opening any more and prefer either to have them open in a new tab or as an overlay on the current page.


    Oh, here's Nikki Lauda, I'm just going to jump on him, not figuratively of course. - Commentator Radio 5 Live

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  8. #8
    Senior Coder deathshadow's Avatar
    Join Date
    Feb 2016
    Location
    Keene, NH
    Posts
    3,091
    Thanks
    4
    Thanked 448 Times in 437 Posts
    @Phillip M has it right that you shouldn't be shoving new windows down the user's gullet -- that's why target was deprecated in HTML 4 and why it being back in 5 is more legacy support of what CAN be done than an indication of what SHOULD be done. Someone wants it in a new window (well, these days tab) they can ctrl+click or middle-click.

    Though we can't see your page at 127.0.0.1 -- that's your local address, invisible to the web at large; so not really a help in diagnosing the problem.

    Also if it only supports IE then you're really up **** creek, given that IE is pretty much officially dead on support and will likely soon no longer even be included with new installs of windows. It's on life support for security patches and that's IT...

    As web developers most only lip-service support for IE11 and say screw the rest -- I'm considered odd in that I write for graceful degradation so those who cannot upgrade don't get a broken page, and that's really going above and beyond when it comes to continuing IE support.

    You really might want to rewrite from scratch if that's your application or find an alternative if not before the two to five years where it flat out will not work anymore expires...

    Since dimes to dollars if it is written as IE "only" it's not going to run in Edge.

    -- edit -- Wait, are you talking about Siebel as in the CRM? What version are you on?!? One prior to Oracle acquiring the property and the original company going bits-up face-down? You might want to consider upgrading to an actual MODERN version instead of trying to shlep by on decade out of date software! My mind shudders at the thought of the security issues alone...

    Even though for all the releases of the past three years, the codebase still has its head wedged up 1997's rump.

    Might be time to consider migrating to Goldmine; the codebase is s*** but at least it's modern s***.
    Last edited by deathshadow; Jul 18th, 2018 at 12:11 AM.
    “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies and the other way is to make it so complicated that there are no obvious deficiencies.” – C.A.R. Hoare, The 1980 ACM Turing Award Lecture
    http://www.cutcodedown.com

  9. #9
    Senior Coder deathshadow's Avatar
    Join Date
    Feb 2016
    Location
    Keene, NH
    Posts
    3,091
    Thanks
    4
    Thanked 448 Times in 437 Posts
    Oh, but you did say js help... so change window.open(''); to window.location.href='';
    “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies and the other way is to make it so complicated that there are no obvious deficiencies.” – C.A.R. Hoare, The 1980 ACM Turing Award Lecture
    http://www.cutcodedown.com

  10. #10
    New to the CF scene
    Join Date
    Jul 2018
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by deathshadow View Post
    Oh, but you did say js help... so change window.open(''); to window.location.href='';
    It didn't worked..


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •