digitup digitup - 3 years ago 174
jQuery Question

How can I set a target to top for a link within an iframe?

in my code for index.html I use jQuery and have a link with id #button3.

I have used in index.html

$('#button3 a').attr({
target: '_top'

When I call the index.html from an iframe as a src, the page opens in _self.
I have tried with _blank and still when clicking on the a link it doesn't open on a new page.

I have this code

//handle click OK button
if (validate()) {

//set the target attribut to return to the parent

$('#button3 a').attr('target', '_parent');

and 2 functions validate and submitQuery don't call the a link at any time.

Answer Source

The correct set-attribute syntax is:

$('#button3 a').attr('target', '_top');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download