When using custom actions in SharePoint (for the Site Actions menu) how can I make it so that the links will open up in a new window?
I have tried an approach using jQuery that would attach a hover event via .live() to replace the window.location with a window.open call -- however this proved to be troublesome as it refused to work in IE6 (which a large portion of our users are still using...).
Its is not possible out of box. But it can be done using little hack. Refer to these links
MSDN Question
Blog Post
Related
I'd like to do the following in my application via javascript.
1) Press a button from a web page that opens a popup.
2) Select some options in the popup and accept them.
3) Change the content of what is in the first web page according to what has been selected in the popup and change it. A GET Request is acceptable, and if possible popup with the selected options should again be on top, either by putting it on top or by opening a new one with the same options chosen.
I think javascript must have some way of saving the name of the browser tabs your are opening and later, if you want, open a new URL, or put one over other but I cannot find them. The window.open options doesn't look like they can do this.
Any idea on how to achieve this thing? Thanks for your time.
You can try the window.opener method in the popup to access the main page. High level details here: http://www.w3schools.com/jsref/prop_win_opener.asp, but if you Google it there's examples.
We did this for a project and it works, with a few caveats:
Cross domain basically doesn't work, if you have multiple domains you have to get more creative.
Be careful cross browser as well, we had to add some custom javascript to handle
Basically, what you need to do on your main page is define a global javascript method that does what you want it to (it can take parameters). Then, on your popup, you can call it with window.opener.MethodNameHere();
Theoretically, if you do need to handle cross browser, you can try using postmessage, which I believe is only supported in html5 natively (there are plugins for html4), but it would probably be tricky getting it right in this circumstance and I'm not sure how to do it off the top of my head.
I need to test a page tracker behavior. The tracker's reporting triggers when links are clicked, however generating a click event on anchor elements doesn't instruct the browser to navigate to the page in the link. I tried Selenium IDE - to no effect.
Is there any way to accomplish this? Perhaps some browser setting? If it is specific to Firefox or Google Chrome or Opera - it doesn't matter, I could use any of those for testing.
Here's a similar question How do I programmatically click a link with javascript? but it doesn't help in my case, as as I just described, no navigation happens in this case.
<a id="gLink" href="http://www.google.com">Google</a>
<script>
document.getElementById("gLink").click()
</script>
Does the trick.
Normally, clicking on an anchor link takes you somewhere else inside the page and changes the anchor link to foo.php#bar (where bar is the name of the anchor), so this behavior is by design.
Here are all the different methods I can think of
Method 1: adapt your tracker
Perhaps you can configure your tracker to track these changes? Clicking on an anchor fires up the hashchange event. Check this SO question
Check these links for ways to utilize the hashchange event:
https://developer.mozilla.org/en-US/docs/Web/API/window.onhashchange
http://oshyn.com/_blog/General/post/JavaScript_Navigation_using_Hash_Change/
Method 2: use the HTML5 history API
You can change your browser's URLs programmatically via the HTML5 pushState() method, i.e. the history API.
Here are some examples of utilizing the HTML history API:
http://diveintohtml5.info/history.html
https://developer.mozilla.org/en-US/docs/Web/Guide/DOM/Manipulating_the_browser_history
I was browsing thought GitHub today and noticed that the individual repository navigation doesn't use hash-bangs in the URL /#! or /# and the back button still works. How do you think they are accomplishing this? How does this affect search engine crawling from Googlebot? I know it looks for # in the url.
I'm really quite curious as I know using /# is quite debatable.
Here's an example: https://github.com/mirah/pindah
Thanks!
They blogged about it a while back:
https://github.com/blog/760-the-tree-slider
The effect is implemented history.pushState() function and handlers on the popstate event — both a part of the HTML5 DOM interface in some browsers.
Clicking the link uses pushState() to update the location and load new data into the page without reloading the whole page. Handling popstate makes the back button work correctly.
The GutHub blog calls their particular usage the “Tree Slider” (it loads the content for tree members and visually slides it into place). The effect and its implementation was described on the GitHub blog.
I'm using Google search in a page, and it shows up in an IFRAME. However, when you click on a link in the search, it's leaving my site and redirecting to that other site. Is there a way to intercept that call with jQuery and make it open that link in a new window, instead?
Due to security reasons, what you can do with an iframe is very limited (In cases where you frame another domain).
The way this is implemented varies a bit from browser to browsers but most browsers won't let you manipulate the data in the iframe.
To my knowledge this isn't possible, assuming you are refering to an implementation of http://www.google.com/cse/
I need to open a popup Window to a cross domain content. I should not allow the user either to access or close the parent window, till i am done with Child window.
The main issue with Modal window is that stops any asynchrnous process running on the main window. For example, timers and auto refresh wont be working in the parent window.
Is there any perfect way to do the above said.
Thanks in advance
How about instead of popping up an actual window, you just open a pseudo-window...that is a div with some borders, make it draggable if you want, and place a large semi-transparent div that covers the rest of the page and blocks it from being clicked on. Basically do something like how Lightbox works
You could use a fake window built via javascript. Several widget libraries have support for this. For example, see ExtJS, which also supports modal windows but it might be overkill for your application. For jQuery, browse through the plugins, like this one
I think Telerik has a control for this if you are working on ASP.Net. Uses a div in its implementation as #Davr suggested. Modal windows are a bad option anyhow as they are not supported on all browsers.
In addition to what Davr and thoriann said, you will likely need to make an Ajax call to grab the content. Since Ajax calls via the browser enforce the same-domain policy, you will need to make an Ajax call to your OWN server, which in-turn will need to make an xmlhttp sever-to-server request to grab the content the third-party server.
I feel the above answers wont fit for the following reasons..
JasonS Solution - The application is developed on J2EE technologies.
Other's solution - Some of the the URL Launched in the child window will communicate to the parent window through standard APIs. If i am using div or other in-built plug-in windows, then those javascript API will fail.
Check out the Jquery plug in "BlockUI". When BlockUI is called the parent window is not accessable. You can do what you want on the modal then call "UnblockUI" to close the popup and give parent control again.
Pete