Skip to content

Commit aabf7f4

Browse files
author
Sathvik Ponangi
committed
Merge pull request #37 from steven777400/steven777400-patch-title
Allow custom title
2 parents 3e5ed11 + f47e28d commit aabf7f4

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ You can submit the options object like:
3535
prepend: null,
3636
manuallyCopyFormValues: true,
3737
deferred: $.Deferred(),
38-
timeout: 250
38+
timeout: 250,
39+
title: null
3940
});
4041
```
4142
@@ -95,6 +96,11 @@ Currently this plugin supports the following options:
9596
- Acceptable-Values: Time in Milliseconds for `setTimeout`
9697
- Function: To change the amount of time to wait for the content, etc to load before printing the element from the new window/iframe created
9798
99+
####title
100+
101+
- Default: `null`, uses the host page title
102+
- Acceptable-Values: Any single-line string
103+
- Function: To change the printed title
98104
99105
## Tested with
100106

jQuery.print.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@
100100
prepend: null,
101101
manuallyCopyFormValues: true,
102102
deferred: $.Deferred(),
103-
timeout: 250
103+
timeout: 250,
104+
title: null
104105
};
105106
// Merge with user-options
106107
options = $.extend({}, defaults, (options || {}));
@@ -126,6 +127,15 @@
126127
.remove();
127128
// Add in the styles
128129
copy.append($styles.clone());
130+
// Update title
131+
if (options.title) {
132+
var title = $("title", copy);
133+
if (title.length === 0) {
134+
title = $("<title />");
135+
copy.append(title);
136+
}
137+
title.text(options.title);
138+
}
129139
// Appedned content
130140
copy.append(getjQueryObject(options.append));
131141
// Prepended content

0 commit comments

Comments
 (0)