Solved

on window open set focus on it

Posted on 2006-06-27
13
605 Views
Last Modified: 2008-01-16
<A  class="bookmarklet" HREF="javascript:void(myRef = window.open('<?=MAIN_PATH?>bookmarklet/index.php?page='+escape(location.href), 'Bookmarklet','menubar=yes,status=yes,location=no,toolbar=no,scrollbars=yes,width=530,resizable=yes,left=200');myRef.focus();)">
<b>anything</b></A>
i have added myRef.focus(); but this link is not workin my requirement is to drag this link to firfox tool bar and focus on this window plz check the error in upper link i have provided to u
and please solve it.
0
Comment
Question by:naeembhatti
  • 6
  • 3
  • 3
  • +1
13 Comments
 
LVL 30

Expert Comment

by:third
ID: 16990810
try this,

<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Author: Third Santor</title>
<script>
  function openWin(url){
    var myRef = window.open(url, 'Bookmarklet', 'menubar=yes,status=yes,location=no,toolbar=no,scrollbars=yes,width=530,resizable=yes,left=200');
    myRef.focus();
  }
</script>
</head>
<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">

<A  class="bookmarklet" HREF="#" onclick="openWin('<?=MAIN_PATH?>bookmarklet/index.php?page='+escape(location.href));return false;">
<b>anything</b></A>
</body>
</html>

i moved the script to a function to make the code more readable.
0
 

Author Comment

by:naeembhatti
ID: 16990827
no i said that i am using this link as a bookmarklet so i need it in herf=""
please give me solution in it .
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 16990851
HREF="javascript:void(myRef = window.open('<?=MAIN_PATH?>bookmarklet/index.php?page='+escape(location.href), 'Bookmarklet','menubar,status,scrollbars,,resizable,width=530,left=200').focus())">
0
 

Author Comment

by:naeembhatti
ID: 16990873
yes this is right but please test it in firefox having drag it on its tool bar
it is not focusing on the pop up window which we opened.
focus is not working ? on herf on firefox?
0
 
LVL 30

Expert Comment

by:callrs
ID: 16990907
<A  class="bookmarklet" HREF="javascript:(function(){myRef = window.open('<?=MAIN_PATH?>bookmarklet/index.php?page='+escape(location.href), 'Bookmarklet','menubar=yes,status=yes,location=no,toolbar=no,scrollbars=yes,width=530,resizable=yes,left=200');myRef.focus();})()">
<b>anything</b></A>
0
 

Author Comment

by:naeembhatti
ID: 16990933
hi callrs it is not focusing on firefox ?
just make a page and paste ur code in it and drag it "anything" hyperlink to ur toolbar of firefox but it is not focusing on it?
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 30

Expert Comment

by:callrs
ID: 16990949
You're right. Window opens but loses focus..
0
 

Author Comment

by:naeembhatti
ID: 16990963
ok now please give me a solution this is my problem callrs.
0
 
LVL 30

Accepted Solution

by:
callrs earned 100 total points
ID: 16990971
<A  class="bookmarklet" HREF="javascript:(function(){myRef = window.open('<?=MAIN_PATH?>bookmarklet/index.php?page='+escape(location.href), 'Bookmarklet','menubar=yes,status=yes,location=no,toolbar=no,scrollbars=yes,width=530,resizable=yes,left=200');setTimeout('myRef.focus()',50);})()">
<b>anything</b></A>
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 16991002
The simple solution is to add a focus to the onLoad in your bookmarklet/index.php
0
 

Author Comment

by:naeembhatti
ID: 16991028
thanks to u all.
yes this is nice solution mplungjan but before loading of window i have 5 functions to run so it takes much time to load it thank u again.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 16991243
<html>
<head>
<script>
window.focus()
.
.
.
</script>
0
 

Author Comment

by:naeembhatti
ID: 16998740
oh , right. yes it is true thank u mplungjan.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
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…

744 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

13 Experts available now in Live!

Get 1:1 Help Now