1

I know this question looks very similar to other questions on this site but I'm in a particular situation and I can't for the life of me figure out how to get this to work. Perhaps it's simple but I can't figure it out. This is my basic dialog function that I want to call onclick with an "a" tag:

<script>
     $('<iframe src="hyperlink" id="tag" frameBorder="0" width="98%" />').dialog({
          autoOpen:false,
          title: 'Documents',
          modal:true,
          autoResize:true,
          resizable:false,
          width: 900,
          height: 400,
          draggable:false,
          open: function(){
               $(this).css('width','98%'
               );
          }
     });

I know using iframes isn't preferable but there's a very specific reason that this is the only way it will work. Apart from that, how could I get a tex to call this dialog box onclick?

2
  • Does the posted code work and you just want to know how to call it on click of an anchor tag? Commented Jun 25, 2011 at 0:32
  • Thank you, yes, the code works onload when I remove the autoOpen line. Commented Jun 25, 2011 at 0:34

1 Answer 1

1

This should work

$("a#thelink").click(function(){
   $("#tag").dialog('open');
});

where thelink is the ID of your link.

Sign up to request clarification or add additional context in comments.

5 Comments

No luck... fyi, my anchor tag is as follows: <a href="#" id="thelink">text</a>
@kingjiv +1 Got your fiddle to load iframe by changing iframe src to yahoo.com. Thanks to both you and kramden88 for teaching me something new.
It certainly does work, thank you. There must be something else wrong on the page. I'll have to investigate but I do appreciate your help!
For any future visitors with a problem like mine (i.e. the code looks good but just won't run onclick) try adding $(window).load(function(){ before the first line. This got it working for me at long last!
Thanks again, it didn't hit me because it had worked onload without it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.