I have created a custom module for Drupal 7. In this module, I would like it execute a javascript file that embeds an iframe when the module is viewed. I have tried the following code with no success:
function chat_with_librarian_block_view($delta = '') {
$block = array();
switch ($delta) {
case 'chat_with_librarian':
$block['subject'] = t('Ask a Librarian');
$block['content'] = chat_with_librarian_get_html();
break;
}
return $block;
}
function chat_with_librarian_get_html() {
$html = '<div id="qpchatwidget" >' .
'</div>' .
'<script ...call site in question with appropriate parameters...>' .
'<noscript>Please enable javascript to chat with librarians online</noscript></script>';
$form = array(
'chat_frame' => array(
'#type' => 'markup',
'#markup' => $html,
'#prefix' => '<div id="parent">',
'#suffix' => '</div>',
)
);
return $form;
}
What do I need to do to get the embedded javascript to work properly. As a side note I can make this work by creating a block through the administration screen, so I know this can be done. I just need to know what I am missing in my code to accomplish the same thing. When I do execute this code, the title is rendered but the body isn't. Examining the body of the block, I can see it contains the javascipt as returned by the function and an additional message:
Reload the page to get source for: url
It seems like the executing code cannot get correct div dimensions to return a proper iframe (but that is just a guess on my part - have put inline css to define a size). Has anyone come across something like this or how to get this working?
Thanks.