Solved

How to access url src and launch in new window

Posted on 2014-11-06
7
154 Views
Last Modified: 2014-12-19
I've got a proprietary site that allows federated searching of internal and external sources. The external sources are returned in a tabbed interface and when you click the tab, the query is submitted to the external source and the results are returned within an iframe. Here's some code:

 $('#fs_tab_2').append("<iframe id='frameInline' name='frameInline' src='http://www.bing.com/search?q=baseball&qs=n&form=QBLH&pq=baseball&sc=8-0&sp=-1&sk=&cvid=36210970a7a34adf844275a81ca9a75e' width='98.8%' height='430' frameborder='0' onLoad=\"setHeight('frameInline');\"></iframe>");

I would like to grab the src from the iframe and -- instead of running the query in the tabbed iframe -- launch a new window and run the query there, i.e., spawn a new window with window.location='http://www.bing.com/search?q=baseball&qs=n&form=QBLH&pq=baseball&sc=8-0&sp=-1&sk=&cvid=36210970a7a34adf844275a81ca9a75e'

Is this possible? I don't know how to get to the iframe src. Can somebody provide the syntax?

Then, I'll need to replace the contents of tab title link <a href="#fs_tab_2">BING SEARCH</a> so the requestor gets the desired results in a new window.

Thanks for all help and guidance.
0
Comment
Question by:GessWurker
  • 4
  • 3
7 Comments
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
Is this possible? I don't know how to get to the iframe src. Can somebody provide the syntax?

Assuming you're not the owner of bing.com, it's not possible.
The only way is to do a screenshot using a dedicated crawler or service on the net using server side code.
0
 

Author Comment

by:GessWurker
Comment Utility
Perhaps I didn't explain things well. I control what's included in the federated search tab. I adjust the plug-in code used by another application (nothing to do with "Bing", per se) to point it to various providers. To add a tab to my application that runs the query against Bing, I include the plug-in code below:

<PluginSetting id="bing_search" DisplayName="Bing™">
<ConstructorParams/>
<Params>
<Param key="Url" type="string">
<Value><![CDATA[http://www.bing.com/search?q={0}]]></Value>
</Param>
<Param key="UrlIsInternal" type="bool">
<Value>False</Value>
</Param>
</Params>
</PluginSetting>

As you can see, all this does is submit whatever terms were run against the internal db against bing, as well. However, the results are returned (by current design) within a tabbed iframe. I'm trying to come up with a workaround. "Bing" could care less. "Bing" won't know the difference. I AM the owner of the application that submits the query in the first place.

Do you still believe it's impossible?
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
it was clear for me.
you can ONLY get content of iframe if it's allowed by the content site or if it's the same domain address
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:GessWurker
Comment Utility
Even though I own the parent window, I can't get to the iframe src?
0
 

Author Comment

by:GessWurker
Comment Utility
Anyway... I thought that since I was loading the iframe, I could access the contents.
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
Comment Utility
No, you can get the source  (src attribute) not the content (html,body,document) of the iframe if it's a different domain.

here the way to get the src : document.getElementById("frameInline").src;

test page : http://jsfiddle.net/twqvytLp/
0
 

Author Comment

by:GessWurker
Comment Utility
Ok. Thanks... that gets me a little closer...
0

Featured Post

Free book by J.Peter Bruzzese, Microsoft MVP

Are you using Office 365? Trying to set up email signatures but you’re struggling with transport rules and connectors? Let renowned Microsoft MVP J.Peter Bruzzese show you how in this exclusive e-book on Office 365 email signatures. Better yet, it’s free!

Join & Write a Comment

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
This tutorial will show how to push an installation of Backup Exec to an additional server in both 2012 and 2014 versions of the software. Click on the Backup Exec button in the upper left corner. From here, select Installation and Licensing, then I…
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…

728 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

9 Experts available now in Live!

Get 1:1 Help Now